/* Scoped to: ss-technology-template-footer */
(function() {
  'use strict';
  var componentRoots = document.querySelectorAll('[data-component-slug="ss-technology-template-footer"]');
  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="ss-technology-template-footer"] ~ ' + 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 () { setTimeout(function () { var rawLaunchDate = "{{launch_date}}"; var rawNotifyEndpoint = "{{notify_api_endpoint}}"; var rawShowCountdown = "{{show_countdown}}"; var defaultDate = "2026-12-31"; function normalizeDate(dateStr) { if (!dateStr || typeof dateStr !== "string") return null; var parts = dateStr.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/); if (parts) { var year = parts[1]; var month = parts[2].padStart(2, "0"); var day = parts[3].padStart(2, "0"); return year + "-" + month + "-" + day; } return dateStr; } var isValidDate = rawLaunchDate && rawLaunchDate.indexOf("{{") === -1; var normalizedDate = isValidDate ? normalizeDate(rawLaunchDate) : null; var CONFIG = { launchDate: normalizedDate || defaultDate, notifyEndpoint: rawNotifyEndpoint, showCountdown: rawShowCountdown !== "false" && rawShowCountdown.indexOf("{{") === -1 ? rawShowCountdown !== "false" : true, }; console.log("[Coming Soon] Launch date:", CONFIG.launchDate); var countdownContainer = document.querySelector("[data-countdown-container]"); if (countdownContainer && CONFIG.showCountdown) { var targetDate = new Date(CONFIG.launchDate + "T23:59:59").getTime(); if (isNaN(targetDate)) { console.error("[Coming Soon] Invalid launch date:", CONFIG.launchDate); targetDate = new Date(defaultDate + "T23:59:59").getTime(); } function updateCountdown() { var now = new Date().getTime(); var distance = targetDate - now; if (distance < 0) { countdownContainer.innerHTML = '<p class="text-2xl text-white font-semibold">We are live! 🎉</p>'; if (window.__comingSoonCountdownInterval) { clearInterval(window.__comingSoonCountdownInterval); window.__comingSoonCountdownInterval = null; } return; } var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); var daysEl = document.querySelector('[data-countdown="days"]'); var hoursEl = document.querySelector('[data-countdown="hours"]'); var minutesEl = document.querySelector('[data-countdown="minutes"]'); var secondsEl = document.querySelector('[data-countdown="seconds"]'); if (daysEl) daysEl.textContent = String(days).padStart(2, "0"); if (hoursEl) hoursEl.textContent = String(hours).padStart(2, "0"); if (minutesEl) minutesEl.textContent = String(minutes).padStart(2, "0"); if (secondsEl) secondsEl.textContent = String(seconds).padStart(2, "0"); } if (window.__comingSoonCountdownInterval) { clearInterval(window.__comingSoonCountdownInterval); } updateCountdown(); window.__comingSoonCountdownInterval = setInterval(updateCountdown, 1000); } var notifyForm = document.querySelector("[data-notify-form]"); var statusEl = document.getElementById("notify-status"); if (notifyForm) { notifyForm.addEventListener("submit", function (e) { e.preventDefault(); var emailInput = notifyForm.querySelector('input[type="email"]'); var submitBtn = notifyForm.querySelector('button[type="submit"]'); var originalText = submitBtn.textContent; submitBtn.textContent = "Subscribing..."; submitBtn.disabled = true; if (CONFIG.notifyEndpoint && CONFIG.notifyEndpoint.indexOf("http") === 0) { fetch(CONFIG.notifyEndpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: emailInput.value }), }) .then(function (res) { if (!res.ok) throw new Error("Failed"); return res.json(); }) .then(function () { showStatus("Thanks! We'll notify you when we launch.", "success"); notifyForm.reset(); }) .catch(function () { showStatus("Something went wrong. Please try again.", "error"); }) .finally(function () { submitBtn.textContent = originalText; submitBtn.disabled = false; }); } else { setTimeout(function () { showStatus("Thanks! We'll notify you when we launch.", "success"); notifyForm.reset(); submitBtn.textContent = originalText; submitBtn.disabled = false; }, 1000); } }); } function showStatus(message, type) { if (!statusEl) return; statusEl.textContent = message; statusEl.className = "mt-4 py-2 px-4 rounded-lg text-sm " + (type === "success" ? "bg-green-500/20 text-black" : "bg-red-500/20 text-red-300"); statusEl.classList.remove("hidden"); } }, 0); })();
  });
})();