/* Scoped to: history-template-destinations-hero */
(function() {
  'use strict';
  var componentRoots = document.querySelectorAll('[data-component-slug="history-template-destinations-hero"]');
  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="history-template-destinations-hero"] ~ ' + 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 destSlides = document.querySelectorAll(".dest-slide"); const titleEl = document.getElementById("destHeroTitle"); const descEl = document.getElementById("destHeroDesc"); const ctaEl = document.getElementById("destHeroCta"); const indexEl = document.getElementById("destSlideIndex"); const progressEl = document.getElementById("destProgressFill"); const content = [ { t: "{{dest_title_1}}", d: "{{dest_desc_1}}", c: "{{dest_cta_text_1}}", }, { t: "{{dest_title_2}}", d: "{{dest_desc_2}}", c: "{{dest_cta_text_2}}", }, { t: "{{dest_title_3}}", d: "{{dest_desc_3}}", c: "{{dest_cta_text_3}}", }, { t: "{{dest_title_4}}", d: "{{dest_desc_4}}", c: "{{dest_cta_text_4}}", }, ]; let i = 0; let startX = 0; let dragging = false; const DURATION = 5000; function update(manual = false) { destSlides.forEach((s) => s.classList.remove("active")); destSlides[i].classList.add("active"); titleEl.textContent = content[i].t; descEl.textContent = content[i].d; ctaEl.textContent = content[i].c; indexEl.textContent = `0${i + 1}`; if (!manual) { progressEl.style.transition = "none"; progressEl.style.width = "0%"; requestAnimationFrame(() => { progressEl.style.transition = "width 5s linear"; progressEl.style.width = "100%"; }); } } function next() { i = (i + 1) % destSlides.length; update(); } function prev() { i = (i - 1 + destSlides.length) % destSlides.length; update(true); } let auto = setInterval(next, DURATION); document.addEventListener("mousedown", (e) => { dragging = true; startX = e.clientX; clearInterval(auto); }); document.addEventListener("mouseup", (e) => { if (!dragging) return; dragging = false; const diff = startX - e.clientX; if (diff > 80) next(); else if (diff < -80) prev(); auto = setInterval(next, DURATION); }); document.addEventListener("touchstart", (e) => { startX = e.touches[0].clientX; clearInterval(auto); }); document.addEventListener("touchend", (e) => { const diff = startX - e.changedTouches[0].clientX; if (diff > 80) next(); else if (diff < -80) prev(); auto = setInterval(next, DURATION); }); update(); })();
  });
})();