(() => { const CARD_SELECTOR = '[data-framer-name="AgendaCard"]'; const MESSAGE_SELECTOR = '[data-framer-name="NoResultsMessage"]'; const INPUT_SELECTOR = 'input[placeholder*="Search"], input[type="search"]'; function initializeAgendaSearch() { const input = document.querySelector(INPUT_SELECTOR); const cards = [...document.querySelectorAll(CARD_SELECTOR)]; const message = document.querySelector(MESSAGE_SELECTOR); if (!input || cards.length === 0 || !message) { return false; } // Preserve the original message display style. if (!message.dataset.originalDisplay) { message.dataset.originalDisplay = getComputedStyle(message).display === "none" ? "flex" : getComputedStyle(message).display; } function filterAgenda() { const query = input.value.trim().toLocaleLowerCase(); let visibleCount = 0; cards.forEach((card) => { const text = (card.innerText || card.textContent || "") .toLocaleLowerCase(); const matches = query === "" || text.includes(query); card.style.setProperty( "display", matches ? "" : "none", "important" ); if (matches) visibleCount++; }); // Show the message only when a non-empty search has zero matches. const showMessage = query !== "" && visibleCount === 0; message.style.setProperty( "display", showMessage ? message.dataset.originalDisplay : "none", "important" ); console.log("Agenda search:", { query, totalCards: cards.length, matchingCards: visibleCount, noResultsVisible: showMessage }); } input.removeEventListener("input", filterAgenda); input.addEventListener("input", filterAgenda); // Handle prefilled searches and the initial page state. filterAgenda(); return true; } if (!initializeAgendaSearch()) { const observer = new MutationObserver(() => { if (initializeAgendaSearch()) { observer.disconnect(); } }); observer.observe(document.body, { childList: true, subtree: true }); // Stop observing after 15 seconds. setTimeout(() => observer.disconnect(), 15000); } })();