const o="/assets/achievement_manager/",r={exampleAchievement:{name:"Woah...",description:"You did it",iconName:`${o}example-icon.png`},exampleGlobalAchievement:{name:"Global",description:"You got a global achievement!",iconName:`${o}example-icon-2.png`}},c=Number(localStorage.getItem("linksClicked"));function a(e){return(Number(e)+1).toString()}document.addEventListener("DOMContentLoaded",()=>{c>=10&&u(r.exampleGlobalAchievement)});document.addEventListener("click",function(e){e.target.closest("a")&&(localStorage.getItem("linksClicked")?localStorage.setItem("linksClicked",a(c)):localStorage.setItem("linksClicked",a(0)))});const d=8e3;function p(e){return`
    <img src=${e.iconName}>
    <div>
        <p>You got an achievement!!</p>
        <p>${e.name}: ${e.description}</p>
    </div>`}function s(e){return e.toLowerCase().trim().replace(/[^a-z0-9']+/g,"-").replace(/'/g,"-").replace(/(^-|-$)/g,"")}let n=[];function l(){console.log(n);const e=document.createElement("div");e.classList.add("achievement-popup"),e.innerHTML=p(n[n.length-1]),document.body.append(e),requestAnimationFrame(()=>{e.classList.add("show")}),setTimeout(()=>{e.classList.remove("show"),e.classList.add("hide"),e.addEventListener("animationend",()=>{e.remove()}),n.pop(),!n.length==0&&l()},d)}function u(e){const t=localStorage.getItem("achievements");let i=t?JSON.parse(t):[];v(e)||(i.push(e),n.push(e),localStorage.setItem("achievements",JSON.stringify(i)),l())}function v(e){const t=localStorage.getItem("achievements");return(t?JSON.parse(t):[]).some(m=>s(m.name)===s(e.name))}export{r as a,v as i,u};
