export interface Toast { id: number; kind: 'info' | 'success' | 'error' | 'event'; text: string; } let nextId = 1; export const toasts = $state([]); export function toast(text: string, kind: Toast['kind'] = 'info', ttlMs = 6000) { const id = nextId++; toasts.push({ id, kind, text }); setTimeout(() => dismiss(id), ttlMs); } export function dismiss(id: number) { const i = toasts.findIndex((t) => t.id === id); if (i >= 0) toasts.splice(i, 1); }