'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const __chunk_1 = require('./chunk-c92d86f4.js');

class MaterialsAlertController {
    constructor(hostRef) {
        __chunk_1.registerInstance(this, hostRef);
    }
    /** Create a HTMLMaterialsDialogElement and returns it */
    async create(opts) {
        const dialog = document.createElement('materials-dialog');
        dialog.dialogTitle = opts.title;
        dialog.actions = [];
        if (opts.cancelText) {
            dialog.actions.push({
                label: opts.cancelText,
                role: 'close',
                action: opts.onCancel
            });
        }
        dialog.actions.push({
            label: opts.acceptText,
            role: 'accept',
            action: opts.onAccept
        });
        dialog.body = opts.message;
        dialog.addEventListener('accept', () => dialog.remove());
        dialog.addEventListener('cancel', () => dialog.remove());
        document.body.appendChild(dialog);
        return dialog;
    }
}

exports.materials_alert_controller = MaterialsAlertController;
