var startedCounting=!1,charityJSON=null,requestCount=0,minutesBetweenUpdates=10,stepsPerMinute=7,mealsCounter=null,daysCounter=null;function setText(t,e,n){"meals"===t?(e.text(`${n}+`),mealsCounter&&mealsCounter.text(n)):"education"===t?(e.text(`${n}+`),daysCounter&&daysCounter.text(n)):e.text(`$${n}+`)}function animateCounter(t,e=0,n=null){startedCounting=!0,$(`[data-stat="${t}"]`).each(function(){var r=$(this),o=n||r.text().replace(/[^\d.-]/g,""),i=String(o).length+2.5;r.css("width",`${i}rem`),$({countNum:e}).animate({countNum:o},{duration:3e3,easing:"swing",step:function(){let e=Math.floor(this.countNum).toLocaleString("en");setText(t,r,e)},complete:function(){let e=this.countNum.toLocaleString("en");setText(t,r,e)}})})}function startObserver(){var t=new IntersectionObserver(function(e){!0!==e[0].isIntersecting||startedCounting||(animateCounter("meals"),animateCounter("education"),animateCounter("everything"),t.disconnect())},{threshold:[1]});t.observe(document.querySelector(".charity-count-bar"))}function charity_ticker_driver(t,e,n,r=0,o=0){var i=Math.ceil((n-e)/minutesBetweenUpdates/stepsPerMinute);0==r&&(r=e,o=e),o+=i,console.log(`Stepping the charity stats (ID: ${t}) from ${r} to ${o} (Start: ${e} End: ${n})`),rn&&animateCounter(t,r,n)}function getCharityJSON(){requestCount>10||(console.log("Getting charity JSON"),fetch("/charity-counter").then(function(t){return t.text()}).then(function(t){const e=(new DOMParser).parseFromString(t,"text/html");charityJSON=JSON.parse(e.getElementById("charity_counter_json").textContent),setTimeout(function(){charity_ticker_driver("meals",charityJSON.meals_donated_previous,charityJSON.meals_donated),charity_ticker_driver("education",charityJSON.education_sponsored_previous,charityJSON.education_sponsored),charity_ticker_driver("everything",charityJSON.total_donations_previous,charityJSON.total_donations)},6e4/stepsPerMinute),setTimeout(getCharityJSON,6e5)}),requestCount++)}window.addEventListener("load",function(){"undefined"==typeof IntersectionObserver?(animateCounter("meals"),animateCounter("education"),animateCounter("everything")):startObserver(),getCharityJSON(),$(".locked-product-title:visible").first().text("Current Meals:"),$(".locked-product-title:visible").last().text("Current Days:"),mealsCounter=$(".locked-product-count:visible").first(),daysCounter=$(".locked-product-count:visible").last(),mealsCounter||console.log("Could not find meals counter"),daysCounter||console.log("Could not find days counter")});