import { useStore } from '@nanostores/react' import type { ReactNode } from 'react' import { Button } from '@/components/ui/button' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' import { Switch } from '@/components/ui/switch' import { useI18n } from '@/i18n' import { COMPLETION_SOUND_VARIANTS, previewCompletionSound } from '@/lib/completion-sound' import { triggerHaptic } from '@/lib/haptics' import { Bell, Play } from '@/lib/icons' import { cn } from '@/lib/utils' import { $completionSoundVariantId, setCompletionSoundVariantId } from '@/store/completion-sound' import { $nativeNotifyPrefs, NATIVE_NOTIFICATION_KINDS, sendTestNativeNotification, setNativeNotifyEnabled, setNativeNotifyKind } from '@/store/native-notifications' import { notify } from '@/store/notifications' import { CONTROL_TEXT } from './constants' import { ListRow, SectionHeading, SettingsContent } from './primitives' const CAPTION = 'text-[length:var(--conversation-caption-font-size)] text-(--ui-text-tertiary)' function Caption({ children, className }: { children: ReactNode; className?: string }) { return

{children}

} function ToggleRow(props: { checked: boolean description: string disabled?: boolean label: string onChange: (on: boolean) => void }) { return ( { triggerHaptic('selection') props.onChange(on) }} /> } description={props.description} title={props.label} /> ) } export function NotificationsSettings() { const { t } = useI18n() const prefs = useStore($nativeNotifyPrefs) const completionSoundVariantId = useStore($completionSoundVariantId) const copy = t.settings.notifications const runTest = async () => { triggerHaptic('open') const ok = await sendTestNativeNotification(copy.testTitle, copy.testBody) notify({ kind: ok ? 'info' : 'error', message: ok ? copy.testSent : copy.testUnsupported }) } return ( {copy.intro}
{NATIVE_NOTIFICATION_KINDS.map(kind => ( setNativeNotifyKind(kind, on)} /> ))}
} description={copy.completionSoundDesc} title={copy.completionSoundTitle} />
{copy.focusedHint}
) }