function windowResize(){document.getElementsByTagName("html")[0].style.zoom=window.innerWidth/1920}function encode(e,t=encodingChars.length){let n="1";for(let i=0;i<e.length;i++){0!=i&&(n+="_");let r=e[i];if(0==r.length)continue;let l=Math.max.apply(null,r)+1,d=[],o=[];for(let e=1;e<10;e++)d.push(e*(Math.log10(l)/Math.log10(t))),o.push(d[e-1]%1);let s=Math.max.apply(null,o),a=o.indexOf(s)+1,c=Math.ceil(d[a-1]),p=l;n+=encodingChars.substr(p%t,1),p=Math.floor(p/t),n+=encodingChars.substr(p%t,1);for(let e=r.length;e%a!=0;e++)r.push(0);for(let e=0;e<r.length;e+=a){let i=0;for(let t=0;t<a;t++)i=i*l+r[e+t];for(let e=0;e<c;e++)n+=encodingChars.substr(i%t,1),i=Math.floor(i/t)}}return n}function decode(e,t=encodingChars.length){if(urlVersion=encodingChars.indexOf(e[0]),"0"==e[0]||"1"==e[0]){let n=[];e=(e=e.substr(1)).split("_");for(let i=0;i<e.length;i++){n.push([]);let r=e[i].split("").map(e=>encodingChars.indexOf(e)),l=0;l=(l=l*t+r[1])*t+r[0],r.shift(),r.shift();let d=[],o=[];for(let e=1;e<10;e++)d.push(e*(Math.log10(l)/Math.log10(t))),o.push(d[e-1]%1);let s=Math.max.apply(null,o),a=o.indexOf(s)+1,c=Math.ceil(d[a-1]);for(let e=0;e<r.length;e+=c){let d=0,o=[];for(let n=c-1;0<=n;n--)d=d*t+r[e+n];for(let e=0;e<a;e++)o.push(d%l),d=Math.floor(d/l);o=o.reverse();for(let e=0;e<a&&0!=o[e];e++)n[i].push(o[e])}}return n}return-1}function EmployWorkers(){window.scrollY>367&&window.scrollTo(0,0);var e=[],t=[];urlPerks=[],urlLocks=[];var n=document.getElementsByClassName("PerkCard");for(i=0;i<n.length;i++)e.push({j:parseInt(n[i].id.split("_")[0]),k:parseInt(n[i].id.split("_")[1])}),t.push(parseInt(n[i].children[1].firstChild.textContent.split(" ")[0].substring(1))/3),urlPerks.push(perkButtonIdList.indexOf(n[i].id));for(0==urlPerks.length&&urlPerks.push(0),0==urlPerks.length&&urlPerks.push(0);workerList.length>0;)workerList[0].terminate(),workerList.shift();var r=new Worker("./js/webWorker.min.js");workerList.push(r),workerList[0].postMessage({indexPerk:e,indexPerkRank:t,lock:getLockIndices(),legendaryWeapon:document.getElementById("LegendaryWeapon").checked}),history.pushState(null,null,"/?"+encode([urlPerks,t,urlLocks])),workerList[0].onmessage=function(e){if(void 0!=e.data.bonusPerks){applyBonusPerksUI(e.data.bonusPerks)}if(void 0!=e.data.set){printTableUI(e.data.set)}}}function MalkarionWeapon(){document.getElementById("MalkarionWeapon").checked?(document.getElementById("LockCheckbox 1_2").checked=!0,document.getElementById("LockCheckbox 1_10").checked=!0,document.getElementById("LockCheckbox 1_19").checked=!0,document.getElementById("LegendaryWeapon").checked=!0):(document.getElementById("LockCheckbox 1_2").checked=!1,document.getElementById("LockCheckbox 1_10").checked=!1,document.getElementById("LockCheckbox 1_19").checked=!1,document.getElementById("LegendaryWeapon").checked=!1),EmployWorkers()}function applyBonusPerksUI(e){for(i=0;i<e.length;i++)"btn disabled"!=document.getElementById(e[i].stringID).className&&(e[i].value>1?document.getElementById(e[i].stringID).className="PerkButton  waves-effect waves-light btn tooltipped plus6":e[i].value>0?document.getElementById(e[i].stringID).className="PerkButton  waves-effect waves-light btn tooltipped plus3":document.getElementById(e[i].stringID).className="PerkButton  waves-effect waves-light btn tooltipped plus0");document.getElementById("Builds Table Body").textContent=""}function clearTableUI(){let e=document.getElementsByTagName("td").length;for(let t=0;t<e;t++)document.getElementsByTagName("td")[t].textContent=""}function printArmorUI(e,t,n){let i=document.createElement("td"),r=document.createElement("div");r.className="PrintEquipment";let l=document.createElement("img");l.src=e.icon,l.className="ArmorIcon",r.appendChild(l);let d=document.createElement("div");d.textContent=e.id,r.appendChild(d),i.appendChild(r),n.appendChild(i)}function printWeaponUI(e,t,n){let i=document.createElement("td"),r=document.createElement("div");r.className="PrintEquipment";let l=document.createElement("img");l.src=e.icon,l.className="ArmorIcon",r.appendChild(l);let d=document.createElement("div");document.getElementById("LegendaryWeapon").checked?d.textContent="Legendary "+e.id+" "+e.type:d.textContent=e.id+" "+e.type,r.appendChild(d),i.appendChild(r),n.appendChild(i)}function generateDBurl(e,t){let n=[3,weapon[e.id[4]][e.id[5]].DBmap,15];perkList[e.cell[4].j][e.cell[4].k].type.name==weapon[e.id[4]][e.id[5]].cell[0]?n.push(perkList[e.cell[4].j][e.cell[4].k].DBmap,perkList[e.cell[5].j][e.cell[5].k].DBmap):perkList[e.cell[4].j][e.cell[4].k].type.name==weapon[e.id[4]][e.id[5]].cell[1]?n.push(perkList[e.cell[5].j][e.cell[5].k].DBmap,perkList[e.cell[4].j][e.cell[4].k].DBmap):n.push(perkList[e.cell[4].j][e.cell[4].k].DBmap,perkList[e.cell[5].j][e.cell[5].k].DBmap),"Repeater"!=weapon[e.id[4]][e.id[5]].type&&document.getElementById("LegendaryWeapon").checked?"Aether Strikers"==weapon[e.id[4]][e.id[5]].type?(n[1]=132,n.push(3,2,0,0,weapon[e.id[4]][e.id[5]].DBmap,0)):"Axe"==weapon[e.id[4]][e.id[5]].type?(n[1]=130,n.push(5,3,0,0,weapon[e.id[4]][e.id[5]].DBmap,0)):"Sword"==weapon[e.id[4]][e.id[5]].type?(n[1]=127,n.push(7,6,0,0,weapon[e.id[4]][e.id[5]].DBmap,0)):"Chain Blades"==weapon[e.id[4]][e.id[5]].type?(n[1]=128,n.push(5,3,0,0,weapon[e.id[4]][e.id[5]].DBmap,0)):"War Pike"==weapon[e.id[4]][e.id[5]].type?(n[1]=131,n.push(5,8,0,0,weapon[e.id[4]][e.id[5]].DBmap,0)):"Hammer"==weapon[e.id[4]][e.id[5]].type?(n[1]=129,n.push(5,1,0,0,weapon[e.id[4]][e.id[5]].DBmap,0)):"Repeater"==weapon[e.id[4]][e.id[5]].type?n.push(0,8,9,19,0,25):n.push(0,0,0,0,0,0):"Aether Strikers"==weapon[e.id[4]][e.id[5]].type?n.push(3,2,0,0,0,0):"Axe"==weapon[e.id[4]][e.id[5]].type?n.push(5,3,0,0,0,0):"Sword"==weapon[e.id[4]][e.id[5]].type?n.push(7,6,0,0,0,0):"Chain Blades"==weapon[e.id[4]][e.id[5]].type?n.push(5,3,0,0,0,0):"War Pike"==weapon[e.id[4]][e.id[5]].type?n.push(5,8,0,0,0,0):"Hammer"==weapon[e.id[4]][e.id[5]].type?n.push(5,1,0,0,0,0):"Repeater"==weapon[e.id[4]][e.id[5]].type?n.push(0,8,9,19,0,25):n.push(0,0,0,0,0,0),n.push(head[e.id[0]].DBmap,15,perkList[e.cell[0].j][e.cell[0].k].DBmap,torso[e.id[1]].DBmap,15,perkList[e.cell[1].j][e.cell[1].k].DBmap,arms[e.id[2]].DBmap,15,perkList[e.cell[2].j][e.cell[2].k].DBmap,legs[e.id[3]].DBmap,15,perkList[e.cell[3].j][e.cell[3].k].DBmap,2,perkList[e.cell[6].j][e.cell[6].k].DBmap);let i=document.createElement("td"),r=document.createElement("a");r.href="https://www.dauntless-builder.com/b/"+hashids.encode(n),r.target="_blank";let l=document.createElement("img");l.src="assets/export.png",l.className="ArmorIcon",r.appendChild(l),i.appendChild(r),t.appendChild(i)}function printTableUI(e){let t=document.createElement("tr");printArmorUI(head[e.id[0]],e.cell[0],t),printArmorUI(torso[e.id[1]],e.cell[1],t),printArmorUI(arms[e.id[2]],e.cell[2],t),printArmorUI(legs[e.id[3]],e.cell[3],t),printWeaponUI(weapon[e.id[4]][e.id[5]],[e.cell[4],e.cell[5]],t),generateDBurl(e,t),BuildsFoundTable.appendChild(t),workerList[0].postMessage(-23)}function PerkClicked(e){let t;t=e.target.classList.contains("plus6")?6:3,e.target.className="btn disabled";let n=document.createElement("div");n.className="animated bounceInLeft faster",document.getElementById("SelectedPerks").appendChild(n);let i=document.createElement("div");i.className="displayHorizontal",i.id=e.target.id,n.appendChild(i);let r=document.createElement("div");r.className="rankChange",i.appendChild(r);let l=document.createElement("img");l.className="rankIcon waves-effect",l.src="assets/upArrow.png",l.addEventListener("click",PlusButtonCLicked),r.appendChild(l);let d=document.createElement("img");d.className="rankIcon",d.src="assets/downArrow.png",d.addEventListener("click",MinusButtonCLicked),r.appendChild(d);let o=document.createElement("div");o.className="PerkCard tooltipped",o.setAttribute("data-position","left");let s="";for(let t=0;t<perkList[parseInt(e.target.id.split("_")[0])][parseInt(e.target.id.split("_")[1])].effect.length;t++)s=s+String(t+1)+": "+perkList[parseInt(e.target.id.split("_")[0])][parseInt(e.target.id.split("_")[1])].effect[t].description+"\n";o.setAttribute("data-tooltip",s),o.id=e.target.id,i.appendChild(o),hasTouch()||M.Tooltip.init(o,{outDuration:0,inDuration:400,enterDelay:500,margin:0,transitionMovement:3});let a=document.createElement("div"),c=document.createElement("img");a.className="PerkCardIcon",c.src="assets/icons/perks/"+cellType[e.target.id.split("_")[0]]+".png",a.appendChild(c),o.appendChild(a);let p=document.createElement("div");p.className="PerkCardText",o.appendChild(p);let m=document.createElement("div");m.className="PerkCardTitle",m.appendChild(document.createTextNode("+"+t+" "+e.target.textContent)),p.appendChild(m),divPerkCardContent=document.createElement("div"),divPerkCardContent.appendChild(document.createTextNode(perkList[parseInt(e.target.id.split("_")[0])][parseInt(e.target.id.split("_")[1])].effect[t-1].description)),p.appendChild(divPerkCardContent),EmployWorkers()}function PlusButtonCLicked(){let e=event.target.parentElement.parentElement.children[1].children[1].firstChild.textContent,t=parseInt(e.split(" ")[0].substring(1)),n=e.substring(e.indexOf(" "));event.target.parentElement.parentElement.children[1].children[1].firstChild.textContent="+"+String(t+3)+" "+n,event.target.parentElement.parentElement.children[1].children[1].children[1].textContent=perkList[parseInt(event.target.parentElement.parentElement.id.split("_")[0])][parseInt(event.target.parentElement.parentElement.id.split("_")[1])].effect[t+3-1].description,EmployWorkers()}function MinusButtonCLicked(){let e=event.target.parentElement.parentElement.children[1].children[1].firstChild.textContent,t=parseInt(e.split(" ")[0].substring(1)),n=e.substring(e.indexOf(" "));t>3?(event.target.parentElement.parentElement.children[1].children[1].firstChild.textContent="+"+String(t-3)+" "+n,event.target.parentElement.parentElement.children[1].children[1].children[1].textContent=perkList[parseInt(event.target.parentElement.parentElement.id.split("_")[0])][parseInt(event.target.parentElement.parentElement.id.split("_")[1])].effect[t-3-1].description):(document.getElementById(event.target.parentElement.parentElement.id).className="waves-effect waves-light btn grey lighten-4 black-text",event.target.parentElement.parentElement.parentElement.remove(event.target.parentElement.parentElement)),EmployWorkers()}function CheckAllClicked(){toggleAllChecboxes(-1==getLockIndices()?!0:!1)}function toggleAllChecboxes(e){for(i=0;i<weapon.length;i++)document.getElementById("LockCheckbox 0 "+String(i)).checked=e;for(j=1;j<armorTypeLength+2;j++)if(j<3)for(i=0;i<idList.length;i++)document.getElementById("LockCheckbox "+String(j)+" "+String(i)).checked=e;else for(i=0;i<idList.length-3;i++)document.getElementById("LockCheckbox "+String(j)+" "+String(i)).checked=e}function getLockIndices(){let e=[];for(e.push([]),i=0;i<weapon.length;i++)document.getElementById("LockCheckbox 0_"+String(i)).checked&&(e[0].push(i),urlLocks.push(LockCheckboxIdList.indexOf("LockCheckbox 0_"+String(i))));for(j=1;j<armorTypeLength+2;j++)if(e.push([]),j<3)for(i=0;i<idList.length;i++)document.getElementById("LockCheckbox "+String(j)+"_"+String(i)).checked&&(e[j].push(i),urlLocks.push(LockCheckboxIdList.indexOf("LockCheckbox "+String(j)+"_"+String(i))));else for(i=0;i<idList.length-3;i++)document.getElementById("LockCheckbox "+String(j)+"_"+String(i)).checked&&(e[j].push(i),urlLocks.push(LockCheckboxIdList.indexOf("LockCheckbox "+String(j)+"_"+String(i))));for(i=0;i<e.length;i++)if(e[i].length>0)return e;return-1}function setCookie(e,t,n){var i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3);var r="expires="+i.toUTCString();document.cookie=e+"="+t+";"+r+";path=/"}function saveFilterConfigCookie(){setCookie("FilterConfigURL",window.location.search.split("_")[2],365)}windowResize(),window.addEventListener("DOMContentLoaded",()=>{let e=document.getElementsByClassName("sliding-tabs");for(let n=0;n<e.length;n++){let r=e[n].getElementsByClassName("navWrapper")[0],l=r.getElementsByTagName("a"),d=r.getElementsByClassName("selector")[0],o=r.getElementsByClassName("active")[0];d.style.left=o.offsetLeft+"px",d.style.width=o.clientWidth+"px";for(let i=0;i<l.length;i++)l[i].addEventListener("click",function(i){i.preventDefault(),function(t){e[n].getElementsByClassName("slider")[0].scroll(t.offsetLeft,0)}(document.getElementById(i.target.href.split("#")[1])),t(i.target)});function t(e){o.classList.remove("active"),(o=e).classList.add("active"),d.style.left=o.offsetLeft+"px",d.style.width=o.clientWidth+"px"}let s=new IntersectionObserver(function(e,n){e.forEach(e=>{if(e.isIntersecting)for(let n=0;n<l.length;n++)l[n].href.split("#")[1]==e.target.id&&t(l[n])})},{root:e[n].getElementsByClassName("slider")[0],threshold:.8}),a=document.getElementsByClassName("slide");for(i=0;i<a.length;i++)s.observe(a[i])}});var perkButtonIdList=[];perkButtonIdList.push("");var perkButtonElems=document.querySelectorAll(".PerkButton");for(let e=0;e<perkButtonElems.length;e++)perkButtonElems[e].addEventListener("click",PerkClicked),perkButtonIdList.push(perkButtonElems[e].id);var LockCheckboxIdList=[];LockCheckboxIdList.push("");var LockCheckboxElems=document.querySelectorAll(".LockCheckbox");for(let e=0;e<LockCheckboxElems.length;e++)LockCheckboxElems[e].addEventListener("click",function(e){"LockCheckbox 1_9"==e.target.id&&document.getElementById("MalkarionWeapon").click()}),LockCheckboxElems[e].addEventListener("click",EmployWorkers),LockCheckboxIdList.push(LockCheckboxElems[e].id);var urlVersion,urlRanks=[],urlPerks=[],urlLocks=[];const encodingChars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-~";var workerList=[],armorTypeLength=4,BuildsFoundTable=document.getElementById("Builds Table Body"),hashids=new Hashids.default("spicy",8,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"),queryString=window.location.search.substr(1);if("0"==queryString[0]){queryString.substr(1),queryString=decode(queryString);for(let e=0;e<queryString[0].length;e++)queryString[0][e]>=19?document.getElementById(perkButtonIdList[queryString[0][e]+1]).click():document.getElementById(perkButtonIdList[queryString[0][e]]).click();PerkCardList=document.getElementsByClassName("PerkCard");for(let e=0;e<queryString[1].length;e++)PerkCardList[e].children[1].firstChild.textContent="+"+String(3*queryString[1][e])+" "+PerkCardList[e].children[1].firstChild.textContent.substring(PerkCardList[e].children[1].firstChild.textContent.indexOf(" ")+1);for(let e=0;e<queryString[2].length;e++)parseInt(document.getElementById(LockCheckboxIdList[queryString[2][e]]).id.split("_")[1])>=9?document.getElementById(LockCheckboxIdList[queryString[2][e]+1]).click():document.getElementById(LockCheckboxIdList[queryString[2][e]]).click();EmployWorkers()}if("1"==queryString[0]){queryString.substr(1),queryString=decode(queryString);for(let e=0;e<queryString[0].length;e++)document.getElementById(perkButtonIdList[queryString[0][e]]).click();var PerkCardList=document.getElementsByClassName("PerkCard");for(let e=0;e<queryString[1].length;e++)PerkCardList[e].children[1].firstChild.textContent="+"+String(3*queryString[1][e])+" "+PerkCardList[e].children[1].firstChild.textContent.substring(PerkCardList[e].children[1].firstChild.textContent.indexOf(" ")+1);for(let e=0;e<queryString[2].length;e++)document.getElementById(LockCheckboxIdList[queryString[2][e]]).click(),17==queryString[2][e]&&(MalkarionWeapon=!0);1==MalkarionWeapon&&(document.getElementById("LockCheckbox 1_9").checked=!0,document.getElementById("LockCheckbox 1_2").checked=!0,document.getElementById("LockCheckbox 1_10").checked=!0,document.getElementById("LockCheckbox 1_19").checked=!0,document.getElementById("LegendaryWeapon").checked=!0),EmployWorkers()}