"use client"; import { useEffect, useState } from 'react'; import { useTranslations } from 'next-intl'; import { usePathname, useRouter } from '@/i18n/navigation'; import { Dialog } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Accessibility } from '@/components/icons'; import { RadioGroup, Select, SettingItem, ToggleSwitch } from '@/components/settings/settings-section'; import { useSettingsStore } from '@/stores/settings-store'; import { useAuthStore } from '@/stores/auth-store'; import { usePolicyStore } from '@/stores/policy-store'; import { FONT_SIZES, type FontSize } from '@/lib/accessibility-settings'; import { useRegisterCommands } from '@/lib/command-registry'; import { ACCESSIBILITY_PRESET_IDS, presetChanges, type AccessibilityPresetId, type PresetChange } from '@/lib/accessibility-presets'; export const ACCESSIBILITY_PANEL_EVENT = 'bulwark:accessibility-panel'; /** Opens the quick accessibility panel from anywhere (rail button, palette). */ export function openAccessibilityPanel(): void { if (typeof window !== 'undefined') window.dispatchEvent(new Event(ACCESSIBILITY_PANEL_EVENT)); } /** * Alt+Shift+A, by physical key so it works on every keyboard layout. A * modifier shortcut, so it stays on when single-key shortcuts are off. */ export function isAccessibilityPanelShortcut(event: KeyboardEvent): boolean { return event.altKey && event.shiftKey && !event.ctrlKey && !event.metaKey && event.code === 'KeyA'; } type SettingKey = Parameters['updateSetting']>[0]; function QuickPanel({ isOpen, onClose, signedIn }: { isOpen: boolean; onClose: () => void; signedIn: boolean }) { const t = useTranslations('accessibility_panel'); const tA = useTranslations('settings.accessibility'); const settings = useSettingsStore(); const { isSettingLocked } = usePolicyStore(); const [applied, setApplied] = useState<{ id: AccessibilityPresetId; changes: PresetChange[] } | null>(null); const set = (key: string, value: unknown) => settings.updateSetting(key as SettingKey, value as never); const applyPreset = (id: AccessibilityPresetId) => { const changes = presetChanges(id, useSettingsStore.getState() as unknown as Record, isSettingLocked); for (const change of changes) set(change.key, change.to); setApplied({ id, changes }); }; const router = useRouter(); const openSettings = () => { onClose(); router.push('/settings/accessibility'); }; return (