/* Scoped to: politician-party-template-engagement-in-action */
(function() {
  'use strict';
  var componentRoots = document.querySelectorAll('[data-component-slug="politician-party-template-engagement-in-action"]');
  componentRoots.forEach(function(componentRoot) {
    // Helper to query within component, with fallback to document for sibling elements
    var $ = function(sel) { 
      return componentRoot.querySelector(sel) || document.querySelector('[data-component-slug="politician-party-template-engagement-in-action"] ~ ' + sel) || document.querySelector(sel);
    };
    var $$ = function(sel) { 
      var results = componentRoot.querySelectorAll(sel);
      return results.length ? results : document.querySelectorAll(sel);
    };
    // Original component JS runs in this scope
    (function () { const track = document.getElementById("engageTrack"); const prevBtn = document.getElementById("prevBtn"); const nextBtn = document.getElementById("nextBtn"); const cards = Array.from(track.querySelectorAll(".engage-card")); if (!track || !prevBtn || !nextBtn || !cards.length) return; let index = 0; function cardsPerView() { if (window.innerWidth <= 640) return 1; if (window.innerWidth <= 1024) return 2; return 3; } function maxIndex() { return Math.max(0, cards.length - cardsPerView()); } function updateSlider() { const perView = cardsPerView(); const translateX = index * (100 / perView); track.style.transform = `translateX(-${translateX}%)`; prevBtn.classList.toggle("active", index > 0); nextBtn.classList.toggle("active", index < maxIndex()); } prevBtn.addEventListener("click", () => { if (index > 0) { index--; updateSlider(); } }); nextBtn.addEventListener("click", () => { if (index < maxIndex()) { index++; updateSlider(); } }); window.addEventListener("resize", () => { index = Math.min(index, maxIndex()); updateSlider(); }); updateSlider(); })();
  });
})();