import Alpine from 'alpinejs'; declare global { interface Window { Alpine: typeof Alpine; } } interface NavigationStore { activeTab: string; init(): void; loadPage(): Promise; } const navigationStore: NavigationStore = { activeTab: '', async init() { await this.loadPage(); window.addEventListener('hashchange', () => this.loadPage()); }, async loadPage() { const tab = window.location.hash.split('/')[1] || 'chats'; if (this.activeTab === tab) return; this.activeTab = tab; const pageContent = document.getElementById('page-content'); if (!pageContent) throw new Error('Failed to find #page-content'); try { const response = await fetch(`/pages/${tab}.html`); if (!response.ok) throw new Error('Failed to load page'); pageContent.innerHTML = await response.text(); } catch (error) { console.error('Page load error:', error); pageContent.innerHTML = `

Failed to load page. Please try again.

`; } }, }; Alpine.store('navigation', navigationStore);