import * as i0 from '@angular/core';
import { Component, Attribute, Inject, Optional, ViewChild, HostListener, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PROP_STRING, PROP_BOOLEAN, PROP_NUMBER, register, provideAsWidgetRef, provideAsDialogRef, WmComponentsModule } from '@wm/components/base';
import * as i1 from '@wm/components/dialogs';
import { BaseDialog, DialogModule } from '@wm/components/dialogs';
import * as i2 from '@wm/components/input';
import { InputModule } from '@wm/components/input';
import { toBoolean } from '@wm/core';

const registerProps = () => {
    register('wm-confirmdialog', new Map([
        ['animation', PROP_STRING],
        ['canceltext', { value: 'CANCEL', ...PROP_STRING }],
        ['class', PROP_STRING],
        ['closable', { value: true, PROP_BOOLEAN }],
        ['iconclass', { value: 'wm-sl-l sl-check', PROP_STRING }],
        ['iconheight', PROP_STRING],
        ['iconmargin', PROP_STRING],
        ['iconurl', PROP_STRING],
        ['iconwidth', PROP_STRING],
        ['message', { value: 'I am confirm box!', ...PROP_STRING }],
        ['modal', { value: false, ...PROP_BOOLEAN }],
        ['name', PROP_STRING],
        ['oktext', { value: 'OK', ...PROP_STRING }],
        ['tabindex', { value: 0, ...PROP_NUMBER }],
        ['headinglevel', { value: 'h4', ...PROP_STRING }],
        ['title', { value: 'Confirm', ...PROP_STRING }]
    ]));
};

const _c0 = ["dialogTemplate"];
const _c1 = ["wmConfirmDialog", ""];
function ConfirmDialogComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelement(0, "div", 1);
    i0.ɵɵelementStart(1, "div", 2)(2, "p");
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(4, "div", 3)(5, "button", 4);
    i0.ɵɵlistener("click", function ConfirmDialogComponent_ng_template_0_Template_button_click_5_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onCancel($event)); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "button", 5);
    i0.ɵɵlistener("click", function ConfirmDialogComponent_ng_template_0_Template_button_click_6_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onOk($event)); });
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("closable", ctx_r1.closable)("iconclass", ctx_r1.iconclass)("iconurl", ctx_r1.iconurl)("iconwidth", ctx_r1.iconwidth)("iconheight", ctx_r1.iconheight)("iconmargin", ctx_r1.iconmargin)("heading", ctx_r1.title)("headinglevel", ctx_r1.headinglevel)("title", ctx_r1.title)("titleid", ctx_r1.titleId);
    i0.ɵɵadvance(2);
    i0.ɵɵclassMapInterpolate1("app-dialog-message ", ctx_r1.messageclass, "");
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r1.message);
    i0.ɵɵadvance(2);
    i0.ɵɵattribute("aria-label", ctx_r1.canceltext);
    i0.ɵɵadvance();
    i0.ɵɵattribute("aria-label", ctx_r1.oktext);
} }
const DIALOG_CLS = 'app-dialog modal-dialog app-confirm-dialog';
const WIDGET_INFO = { widgetType: 'wm-confirmdialog' };
class ConfirmDialogComponent extends BaseDialog {
    static { this.initializeProps = registerProps(); }
    constructor(inj, dialogClass, modal, closable, explicitContext) {
        if (modal === null || modal === undefined) {
            modal = false;
        }
        if (closable === null || closable === undefined) {
            closable = true;
        }
        // setting the backdrop to 'static' will not close the dialog on backdrop click
        const backdrop = 'static';
        super(inj, WIDGET_INFO, {
            class: `${DIALOG_CLS} ${dialogClass || ''}`,
            backdrop,
            keyboard: !toBoolean(modal)
        }, explicitContext);
    }
    onEscape($event) { }
    ;
    getTemplateRef() {
        return this.dialogTemplate;
    }
    /**
     * Click event handler for the ok button
     * invokes on-ok event callback
     * @param {Event} $event
     */
    onOk($event) {
        this.invokeEventCallback('ok', { $event });
    }
    /**
     * Click event handler for the cancel button
     * invokes on-cancel event callback
     * @param {Event} $event
     */
    onCancel($event) {
        this.invokeEventCallback('cancel', { $event });
    }
    ngOnInit() {
        super.ngOnInit();
        this.register(this.viewParent);
    }
    static { this.ɵfac = function ConfirmDialogComponent_Factory(t) { return new (t || ConfirmDialogComponent)(i0.ɵɵdirectiveInject(i0.Injector), i0.ɵɵinjectAttribute('class'), i0.ɵɵinjectAttribute('modal'), i0.ɵɵinjectAttribute('closable'), i0.ɵɵdirectiveInject('EXPLICIT_CONTEXT', 8)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ConfirmDialogComponent, selectors: [["div", "wmConfirmDialog", ""]], viewQuery: function ConfirmDialogComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0, 7);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dialogTemplate = _t.first);
        } }, hostBindings: function ConfirmDialogComponent_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("keydown.esc", function ConfirmDialogComponent_keydown_esc_HostBindingHandler($event) { return ctx.onEscape($event); }, false, i0.ɵɵresolveWindow);
        } }, features: [i0.ɵɵProvidersFeature([
                provideAsWidgetRef(ConfirmDialogComponent),
                provideAsDialogRef(ConfirmDialogComponent)
            ]), i0.ɵɵInheritDefinitionFeature], attrs: _c1, decls: 2, vars: 0, consts: [["dialogTemplate", ""], ["wmDialogHeader", "", 3, "closable", "iconclass", "iconurl", "iconwidth", "iconheight", "iconmargin", "heading", "headinglevel", "title", "titleid"], ["wmDialogBody", ""], ["wmDialogFooter", ""], ["caption.bind", "canceltext", "wmButton", "", 1, "btn-default", "cancel-action", 3, "click"], ["caption.bind", "oktext", "wmButton", "", 1, "btn-primary", "ok-action", 3, "click"]], template: function ConfirmDialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, ConfirmDialogComponent_ng_template_0_Template, 7, 16, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
        } }, dependencies: [i1.DialogBodyDirective, i1.DialogFooterDirective, i1.DialogHeaderComponent, i2.ButtonComponent], encapsulation: 2 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConfirmDialogComponent, [{
        type: Component,
        args: [{ selector: 'div[wmConfirmDialog]', providers: [
                    provideAsWidgetRef(ConfirmDialogComponent),
                    provideAsDialogRef(ConfirmDialogComponent)
                ], template: "<ng-template #dialogTemplate>\n    <div wmDialogHeader [closable]=\"closable\"\n         [iconclass]=\"iconclass\"\n         [iconurl]=\"iconurl\"\n         [iconwidth]=\"iconwidth\"\n         [iconheight]=\"iconheight\"\n         [iconmargin]=\"iconmargin\"\n         [heading]=\"title\"\n         [headinglevel]=\"headinglevel\"\n         [title]=\"title\"\n         [titleid]=\"titleId\"></div>\n    <div wmDialogBody>\n        <p class=\"app-dialog-message {{messageclass}}\">{{ message }}</p>\n    </div>\n    <div wmDialogFooter>\n        <button (click)=\"onCancel($event)\" [attr.aria-label]=\"canceltext\" caption.bind=\"canceltext\" class=\"btn-default cancel-action\"\n                wmButton></button>\n        <button (click)=\"onOk($event)\" [attr.aria-label]=\"oktext\" caption.bind=\"oktext\" class=\"btn-primary ok-action\"\n                wmButton></button>\n    </div>\n</ng-template>\n" }]
    }], () => [{ type: i0.Injector }, { type: undefined, decorators: [{
                type: Attribute,
                args: ['class']
            }] }, { type: undefined, decorators: [{
                type: Attribute,
                args: ['modal']
            }] }, { type: undefined, decorators: [{
                type: Attribute,
                args: ['closable']
            }] }, { type: undefined, decorators: [{
                type: Inject,
                args: ['EXPLICIT_CONTEXT']
            }, {
                type: Optional
            }] }], { dialogTemplate: [{
            type: ViewChild,
            args: ['dialogTemplate', { static: true }]
        }], onEscape: [{
            type: HostListener,
            args: ['window:keydown.esc', ['$event']]
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ConfirmDialogComponent, { className: "ConfirmDialogComponent", filePath: "confirm-dialog.component.ts", lineNumber: 31 }); })();

const components = [
    ConfirmDialogComponent
];
class ConfirmDialogModule {
    static { this.ɵfac = function ConfirmDialogModule_Factory(t) { return new (t || ConfirmDialogModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ConfirmDialogModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            DialogModule,
            InputModule,
            WmComponentsModule] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConfirmDialogModule, [{
        type: NgModule,
        args: [{
                imports: [
                    CommonModule,
                    DialogModule,
                    InputModule,
                    WmComponentsModule
                ],
                declarations: [...components],
                exports: [...components]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ConfirmDialogModule, { declarations: [ConfirmDialogComponent], imports: [CommonModule,
        DialogModule,
        InputModule,
        WmComponentsModule], exports: [ConfirmDialogComponent] }); })();

/**
 * Generated bundle index. Do not edit.
 */

export { ConfirmDialogComponent, ConfirmDialogModule };
//# sourceMappingURL=index.mjs.map
