import{g as l}from"./fingerprint-374ab551.js";const c=async(a,o)=>{if(await m(a,"","start",o),localStorage.theSecondGameIsCompleted){let e=JSON.parse(localStorage.theSecondGameIsCompleted),s=new Date(e.date);switch(Math.floor((new Date().getTime()-s.getTime())/(1e3*3600*24))){case 7:e[7]||(e[7]=!0,fbq("trackCustom","7DaysRetention"),localStorage.setItem("theSecondGameIsCompleted",JSON.stringify(e)));break;case 14:e[14]||(e[14]=!0,fbq("trackCustom","14DaysRetention"),localStorage.setItem("theSecondGameIsCompleted",JSON.stringify(e)));break;case 30:e[30]||(e[30]=!0,fbq("trackCustom","30DaysRetention"),localStorage.setItem("theSecondGameIsCompleted",JSON.stringify(e)));break}}},d=async(a,o,e)=>{await m(a,o,"end",e),n()},n=()=>{if(!JSON.parse(localStorage.fbpgames).firstGameCompleted){localStorage.setItem("fbpgames",JSON.stringify({firstGameCompleted:!0,secondGameCompleted:!1}));return}localStorage.fbpgames&&JSON.parse(localStorage.fbpgames).userComesToSite&&JSON.parse(localStorage.fbpgames).firstGameCompleted&&(localStorage.setItem("fbpgames",JSON.stringify({firstGameCompleted:!0,secondGameCompleted:!0})),JSON.parse(localStorage.fbpgames).secondGameCompleted&&(fbq("trackCustom","TheSecondGameIsCompleted"),localStorage.setItem("fbpgames",JSON.stringify({firstGameCompleted:!1,secondGameCompleted:!1})),localStorage.theSecondGameIsCompleted||localStorage.setItem("theSecondGameIsCompleted",JSON.stringify({date:new Date().toISOString().split("T")[0],7:!1,14:!1,30:!1}))))},m=async(a,o,e,s)=>{const t=new FormData;t.append("_token",document.querySelector('meta[name="csrf-token"]').getAttribute("content")),t.append("name",a),t.append("type",o),t.append("action",e),t.append("visitor_id",await l()),t.append("game_id",s),t.append("from_fb",!!sessionStorage.fbclid),fetch("/game-statistic",{method:"POST",body:t})};export{d as a,c as g};