import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useEffect, useState } from 'react';
import { CheckCircle, XCircle, Loader2, CreditCard, ExternalLink, } from 'lucide-react';
import { useToastStore, } from '../../stores/toastStore';
const icons = {
    default: _jsx(CreditCard, { className: "h-4 w-4" }),
    success: _jsx(CheckCircle, { className: "h-4 w-4 text-green-500" }),
    error: _jsx(XCircle, { className: "h-4 w-4 text-red-500" }),
    loading: _jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
};
function ToastItem({ toast }) {
    const [isVisible, setIsVisible] = useState(false);
    const removeToast = useToastStore((s) => s.removeToast);
    useEffect(() => {
        requestAnimationFrame(() => setIsVisible(true));
    }, []);
    const handleDismiss = () => {
        setIsVisible(false);
        setTimeout(() => removeToast(toast.id), 150);
    };
    return (
    // biome-ignore lint/a11y/useKeyWithClickEvents: toast click-to-dismiss is supplementary
    _jsxs("div", { className: `
				flex items-center gap-3 px-4 py-3
				bg-card border border-border rounded-lg shadow-lg
				transition-all duration-150 ease-out cursor-pointer
				hover:bg-accent/50
				${isVisible ? 'opacity-100 translate-y-0' : 'opacity-0 translate-y-2'}
			`, onClick: handleDismiss, role: "alert", children: [icons[toast.type], _jsx("span", { className: "text-sm text-foreground", children: toast.message }), toast.action && (_jsxs("a", { href: toast.action.href, target: "_blank", rel: "noopener noreferrer", onClick: (e) => e.stopPropagation(), className: "ml-auto flex items-center gap-1 text-xs text-primary hover:underline", children: [toast.action.label, _jsx(ExternalLink, { className: "h-3 w-3" })] }))] }));
}
export function Toaster() {
    const toasts = useToastStore((s) => s.toasts);
    if (toasts.length === 0)
        return null;
    return (_jsx("div", { className: "fixed bottom-4 right-4 z-[9999] flex flex-col gap-2 max-w-sm", children: toasts.map((toast) => (_jsx(ToastItem, { toast: toast }, toast.id))) }));
}
//# sourceMappingURL=Toaster.js.map