declare global { interface Window { Telegram?: { WebApp?: { ready?: () => void expand?: () => void initData?: string colorScheme?: 'light' | 'dark' themeParams?: Record } } } } export function getTelegramInitData(): string | undefined { return window.Telegram?.WebApp?.initData || undefined } export function applyTelegramTheme(): void { const webApp = window.Telegram?.WebApp webApp?.ready?.() webApp?.expand?.() const theme = webApp?.themeParams || {} const root = document.documentElement Object.entries(theme).forEach(([key, value]) => { if (typeof value === 'string') root.style.setProperty(`--tg-${key.replaceAll('_', '-')}`, value) }) if (webApp?.colorScheme) root.dataset.theme = webApp.colorScheme } export {}