{"version":3,"file":"counter_controller-DT4AUxEU.js","names":[],"sources":["../../../app/javascript/entrypoints/controllers/counter_controller.js"],"sourcesContent":["import { Controller } from \"@hotwired/stimulus\";\n\nexport default class extends Controller {\n static targets = [\"number\"];\n static values = { duration: { type: Number, default: 2000 } };\n\n connect() {\n this.animated = false;\n this.observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting && !this.animated) {\n this.animated = true;\n this.animateAll();\n }\n });\n },\n { threshold: 0.3 }\n );\n this.observer.observe(this.element);\n }\n\n disconnect() {\n this.observer.disconnect();\n }\n\n animateAll() {\n this.numberTargets.forEach((el) => {\n const target = parseInt(el.dataset.counterTarget_value || el.dataset.value, 10);\n this.animateNumber(el, target);\n });\n }\n\n animateNumber(el, target) {\n const duration = this.durationValue;\n const start = performance.now();\n\n const step = (now) => {\n const elapsed = now - start;\n const progress = Math.min(elapsed / duration, 1);\n const eased = 1 - Math.pow(1 - progress, 3);\n const current = Math.floor(eased * target);\n el.textContent = current + \"+\";\n\n if (progress < 1) {\n requestAnimationFrame(step);\n } else {\n el.textContent = target + \"+\";\n }\n };\n\n requestAnimationFrame(step);\n }\n}\n"],"mappings":"4GAEA,EAAA,cAA6B,CAAW,CACtC,OAAO,QAAU,CAAC,SAAS,CAC3B,OAAO,OAAS,CAAE,SAAU,CAAE,KAAM,OAAQ,QAAS,IAAM,CAAE,CAE7D,SAAU,CACR,KAAK,SAAW,GAChB,KAAK,SAAW,IAAI,qBACjB,GAAY,CACX,EAAQ,QAAS,GAAU,CACrB,EAAM,gBAAkB,CAAC,KAAK,WAChC,KAAK,SAAW,GAChB,KAAK,YAAY,GAEnB,EAEJ,CAAE,UAAW,GAAK,CACnB,CACD,KAAK,SAAS,QAAQ,KAAK,QAAQ,CAGrC,YAAa,CACX,KAAK,SAAS,YAAY,CAG5B,YAAa,CACX,KAAK,cAAc,QAAS,GAAO,CACjC,IAAM,EAAS,SAAS,EAAG,QAAQ,qBAAuB,EAAG,QAAQ,MAAO,GAAG,CAC/E,KAAK,cAAc,EAAI,EAAO,EAC9B,CAGJ,cAAc,EAAI,EAAQ,CACxB,IAAM,EAAW,KAAK,cAChB,EAAQ,YAAY,KAAK,CAEzB,EAAQ,GAAQ,CACpB,IAAM,EAAU,EAAM,EAChB,EAAW,KAAK,IAAI,EAAU,EAAU,EAAE,CAC1C,EAAQ,GAAa,EAAI,IAAU,EAEzC,EAAG,YADa,KAAK,MAAM,EAAQ,EAAO,CACf,IAEvB,EAAW,EACb,sBAAsB,EAAK,CAE3B,EAAG,YAAc,EAAS,KAI9B,sBAAsB,EAAK"}