/* Scoped to: politician-party-template-header */
(function() {
  'use strict';
  var componentRoots = document.querySelectorAll('[data-component-slug="politician-party-template-header"]');
  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-header"] ~ ' + 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
    const toggle = document.getElementById("partyMenuToggle"); const innerToggle = document.getElementById("partyMenuToggleInner"); const menu = document.getElementById("partyMobileMenu"); const icon = document.getElementById("menuIcon"); function toggleMenu() { menu.classList.toggle("open"); icon.classList.toggle("open"); } toggle?.addEventListener("click", toggleMenu); innerToggle?.addEventListener("click", toggleMenu); const currentPath = window.location.pathname .replace(/\/$/, "") .split("/") .pop(); document.querySelectorAll(".party-nav-link").forEach((link) => { const href = link.getAttribute("href"); if (href === currentPath || (href === "home" && currentPath === "")) { link.classList.add("active"); } });
  });
})();