import { r as registerInstance, c as getElement } from './core-b78a8f7e.js';

const ToastController = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    /**
     * Dismiss all toasts.
     */
    async dismissAll() {
        Array.from(this.element.querySelectorAll('anj-toast')).forEach(toast => {
            toast.dismiss();
        });
    }
    /**
     * Pop a toast for bad things.
     * The first argument is the message, and the second is an optional header.
     */
    async error(message, header) {
        return this.createToast({ message, header, context: 'danger' });
    }
    /**
     * Pop a toast for whatever, we're all nihilists with neutral toasts
     * The first argument is the message, and the second is an optional header.
     */
    async message(message, header) {
        return this.createToast({ message, header });
    }
    /**
     * Pop a toast for good things.
     * The first argument is the message, and the second is an optional header.
     */
    async success(message, header) {
        return this.createToast({ message, header, context: 'success' });
    }
    /**
     * Pop a toast for things that aren't awful, but not great either.
     * The first argument is the message, and the second is an optional header.
     */
    async warn(message, header) {
        return this.createToast({ message, header, context: 'warn' });
    }
    createToast(config) {
        const toast = Object.assign(this.element.ownerDocument.createElement('anj-toast'), config);
        this.element.insertBefore(toast, this.element.firstElementChild);
        return toast;
    }
    get element() { return getElement(this); }
    static get style() { return ".sc-anj-toast-controller-h {\n  position: fixed;\n  top: 1rem;\n  right: 1rem;\n  width: 350px;\n  z-index: 1070;\n}"; }
};

export { ToastController as anj_toast_controller };
