document.addEventListener('DOMContentLoaded', () => { const keyResultsContainer = document.getElementById('keyResultsContainer'); const addKeyResultButton = document.querySelector('[data-add-key-result]'); const searchInput = document.querySelector('[data-search-input]'); const flash = document.querySelector('.app-flash'); const feedContainers = [...document.querySelectorAll('[data-feed-url]')]; const notificationCount = document.getElementById('notificationCount'); const escapeHtml = (value = '') => String(value) .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); const formatUtc = (value) => { if (!value) return '—'; const date = new Date(String(value).replace(' ', 'T') + 'Z'); if (Number.isNaN(date.getTime())) return value; return new Intl.DateTimeFormat(undefined, { month: 'short', day: 'numeric', year: 'numeric', hour: '2-digit', minute: '2-digit' }).format(date); }; const showToast = (message, type = 'success') => { if (!message || !window.bootstrap) return; let container = document.querySelector('.toast-container'); if (!container) { container = document.createElement('div'); container.className = 'toast-container position-fixed top-0 end-0 p-3'; document.body.appendChild(container); } const tone = type === 'danger' ? 'text-bg-dark' : 'text-bg-success'; const toast = document.createElement('div'); toast.className = `toast align-items-center border-0 ${tone}`; toast.role = 'alert'; toast.ariaLive = 'assertive'; toast.ariaAtomic = 'true'; toast.innerHTML = `