import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useCallback, useMemo } from 'react';
import { toast } from 'sonner';
import { Toaster } from '../components/ui/sonner.js';
import { Button } from '../components/ui/button.js';
import { useSound } from './use-sound.js';
const SEVERITY_SOUNDS = {
    success: 'celebration',
    error: 'caution',
    warning: 'notification',
    info: 'button',
};
function NotificationDemo() {
    const successSound = useSound('celebration', { volume: 0.5 });
    const errorSound = useSound('caution', { volume: 0.5 });
    const warningSound = useSound('notification', { volume: 0.5 });
    const infoSound = useSound('button', { volume: 0.5 });
    const soundsByName = useMemo(() => ({
        celebration: successSound,
        caution: errorSound,
        notification: warningSound,
        button: infoSound,
    }), [successSound, errorSound, warningSound, infoSound]);
    const simulateNotification = useCallback((event) => {
        const method = event.severity ?? 'info';
        toast[method](event.featureName, { description: event.message });
        const soundName = SEVERITY_SOUNDS[event.severity];
        soundsByName[soundName]?.play();
    }, [soundsByName]);
    return (_jsx("div", { className: "flex w-[420px] flex-col gap-6", children: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("h3", { className: "text-sm font-semibold", children: "Simulate Notification Events" }), _jsx("p", { className: "text-muted-foreground text-xs", children: "Click a button to fire a toast and sound." }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { size: "sm", variant: "outline", onClick: () => simulateNotification({
                                eventType: 'agent_started',
                                severity: 'info',
                                featureName: 'Auth Module',
                                message: 'Agent started running',
                            }), children: "Agent Started" }), _jsx(Button, { size: "sm", variant: "outline", onClick: () => simulateNotification({
                                eventType: 'phase_completed',
                                severity: 'info',
                                featureName: 'Auth Module',
                                message: 'Completed analyze phase',
                                phaseName: 'analyze',
                            }), children: "Phase Completed" }), _jsx(Button, { size: "sm", variant: "secondary", onClick: () => simulateNotification({
                                eventType: 'waiting_approval',
                                severity: 'warning',
                                featureName: 'Auth Module',
                                message: 'Waiting for user approval',
                            }), children: "Waiting Approval" }), _jsx(Button, { size: "sm", onClick: () => simulateNotification({
                                eventType: 'agent_completed',
                                severity: 'success',
                                featureName: 'Auth Module',
                                message: 'Agent completed successfully',
                            }), children: "Agent Completed" }), _jsx(Button, { size: "sm", variant: "destructive", onClick: () => simulateNotification({
                                eventType: 'agent_failed',
                                severity: 'error',
                                featureName: 'Auth Module',
                                message: 'Agent failed: token refresh error',
                            }), children: "Agent Failed" })] })] }) }));
}
const meta = {
    title: 'Hooks/useNotifications',
    parameters: {
        layout: 'centered',
    },
    tags: ['autodocs'],
    decorators: [
        (Story) => (_jsxs(_Fragment, { children: [_jsx(Story, {}), _jsx(Toaster, {})] })),
    ],
};
export default meta;
export const Default = {
    render: () => _jsx(NotificationDemo, {}),
};
