/** * Navigation v1.6.1 * Enhanced secure version with improved performance, accessibility, usability, * security, and maintainability - Fixed null error and adjusted to flex display */ class Navigation { static instances = new WeakMap(); static getInstance(element) { const el = typeof element === 'string' ? document.querySelector(element) : element; return el instanceof Element ? Navigation.instances.get(el) : null; } static initAll(selector, options = {}) { if (typeof selector !== 'string') throw new Error('Invalid selector'); return Array.from(document.querySelectorAll(selector)) .map(element => new Navigation(element, options)); } static initOnLoad(options = {}) { document.addEventListener('DOMContentLoaded', () => { Navigation.initAll('.navigation', options); }); } static destroyAll() { Navigation.instances.forEach(instance => instance.destroy()); } static sanitizeHTML(str) { if (typeof str !== 'string') return ''; const temp = document.createElement('div'); temp.textContent = str; return temp.innerHTML.replace(/(on\w+)=["'][^"']*["']/gi, ''); } static isValidUrl(url) { if (typeof url !== 'string') return false; if (url === '#') return true; try { new URL(url, window.location.origin); return true; } catch { return false; } } constructor(element, options = {}) { if (!(element instanceof Element)) throw new Error('Invalid element provided'); if (!element.querySelector('ul')) throw new Error('Navigation element must contain a