import { windowExists } from '../utils/window-exists';
function getToastContainer() {
    const container = customElements.get('w-toast-container');
    return container;
}
/**
 * Creates a new toast
 */
export function toast(message, options) {
    if (!windowExists)
        return;
    const toast = getToastContainer().init();
    const data = {
        id: Date.now().toString(36) + Math.random().toString(36).slice(2, 5),
        text: message,
        duration: 5000,
        type: 'success',
        ...options,
    };
    toast.set(data);
    return data;
}
/**
 * Remove an existing toast
 */
export function removeToast(id) {
    if (!windowExists)
        return;
    const toast = getToastContainer().init();
    return toast.del(id);
}
/**
 * Update an existing toast
 */
export function updateToast(id, options) {
    if (!windowExists)
        return;
    const toast = getToastContainer().init();
    toast.set({ ...toast.get(id), ...options });
    return toast.get(id);
}
