{"version":3,"file":"js/promotion_counter-f767ddec8ace6699d131.js","mappings":"8EAAAA,SAASC,iBAAiB,oBAAoB,WAC5C,MAAMC,EAAiBF,SAASG,cAAc,kBAE9C,IAAKD,EAAgB,OAErB,MAAME,EAAcF,EAAeC,cAAc,iBAC3CE,EAAgBH,EAAeC,cAAc,oBAC7CG,EAAeJ,EAAeK,QAAQC,IACtCC,EAAWC,SAASR,EAAeK,QAAQI,IAAK,IAGtDC,eAAeC,IACb,IACE,MAAMC,QAAiBC,MAAMT,GACvBU,QAAaF,EAASG,OAE5B,IAAKD,EAAKE,UAER,YADAC,OAAOC,SAASC,KAAO,uBAKzBjB,EAAYkB,MAAMC,MAAS,GAAEP,EAAKQ,WAClCpB,EAAYqB,aAAa,gBAAiBT,EAAKU,WAG/CrB,EAAcsB,YAAe,GAAEX,EAAKU,gBAAgBjB,oBAGhDO,EAAKU,UAAY,KACnBxB,EAAe0B,UAAUC,IAAI,cAEjC,CAAE,MAAOC,GACPC,QAAQD,MAAM,oCAAqCA,EACrD,CACF,CAGAjB,IAGA,MAAMmB,EAAWC,YAAYpB,EAAe,KAG5CM,OAAOlB,iBAAiB,gBAAgB,WACtCiC,cAAcF,EAChB,GACF,G","sources":["webpack://app/./app/javascript/packs/promotion_counter.js"],"sourcesContent":["document.addEventListener('DOMContentLoaded', function() {\n const counterElement = document.querySelector('.spots-counter');\n\n if (!counterElement) return;\n\n const progressBar = counterElement.querySelector('.progress-bar');\n const remainingText = counterElement.querySelector('.spots-remaining');\n const promotionUrl = counterElement.dataset.url;\n const maxSpots = parseInt(counterElement.dataset.max, 10);\n\n // Function to update the counter\n async function updateCounter() {\n try {\n const response = await fetch(promotionUrl);\n const data = await response.json();\n\n if (!data.available) {\n window.location.href = '/promotions/expired';\n return;\n }\n\n // Update progress bar\n progressBar.style.width = `${data.percent}%`;\n progressBar.setAttribute('aria-valuenow', data.remaining);\n\n // Update text counter\n remainingText.textContent = `${data.remaining} of ${maxSpots} spots remaining`;\n\n // Additional visual feedback if spots are running low\n if (data.remaining < 100) {\n counterElement.classList.add('running-low');\n }\n } catch (error) {\n console.error('Error updating promotion counter:', error);\n }\n }\n\n // Update immediately, then set interval\n updateCounter();\n\n // Update every 30 seconds\n const interval = setInterval(updateCounter, 30000);\n\n // Clean up interval when page changes\n window.addEventListener('beforeunload', function() {\n clearInterval(interval);\n });\n});\n"],"names":["document","addEventListener","counterElement","querySelector","progressBar","remainingText","promotionUrl","dataset","url","maxSpots","parseInt","max","async","updateCounter","response","fetch","data","json","available","window","location","href","style","width","percent","setAttribute","remaining","textContent","classList","add","error","console","interval","setInterval","clearInterval"],"sourceRoot":""}