import { Component } from '@angular/core';
import { Subject } from 'rxjs';
import * as i0 from "@angular/core";
import * as i1 from "../../../providers/localization/localization.service";
import * as i2 from "@clr/angular";
import * as i3 from "@angular/common";
import * as i4 from "@angular/cdk/bidi";
import * as i5 from "./dialog-component-outlet.component";
/**
 * This component should only be instantiated dynamically by the ModalService. It should not be used
 * directly in templates. See {@link ModalService.fromComponent} method for more detail.
 */
export class ModalDialogComponent {
    /**
     *
     */
    constructor(localizationService) {
        this.localizationService = localizationService;
        this.titleTemplateRef$ = new Subject();
        this.buttonsTemplateRef$ = new Subject();
    }
    ngOnInit() {
        this.direction$ = this.localizationService.direction$;
    }
    /**
     * This callback is invoked when the childComponentType is instantiated in the
     * template by the {@link DialogComponentOutletComponent}.
     * Once we have the instance, we can set the resolveWith function and any
     * locals which were specified in the config.
     */
    onCreate(componentInstance) {
        componentInstance.resolveWith = (result) => {
            this.closeModal(result);
        };
        if (this.options && this.options.locals) {
            // eslint-disable-next-line
            for (const key in this.options.locals) {
                componentInstance[key] = this.options.locals[key];
            }
        }
    }
    /**
     * This should be called by the {@link DialogTitleDirective} only
     */
    registerTitleTemplate(titleTemplateRef) {
        this.titleTemplateRef$.next(titleTemplateRef);
    }
    /**
     * This should be called by the {@link DialogButtonsDirective} only
     */
    registerButtonsTemplate(buttonsTemplateRef) {
        this.buttonsTemplateRef$.next(buttonsTemplateRef);
    }
    /**
     * Called when the modal is closed by clicking the X or the mask.
     */
    modalOpenChange(status) {
        if (status === false) {
            this.closeModal();
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: ModalDialogComponent, deps: [{ token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.2", type: ModalDialogComponent, selector: "vdr-modal-dialog", ngImport: i0, template: "<div [dir]=\"direction$ | async\">\n    <clr-modal [clrModalOpen]=\"true\" (clrModalOpenChange)=\"modalOpenChange($event)\"\n        [clrModalClosable]=\"options?.closable\" [clrModalSize]=\"options?.size\"\n        [ngClass]=\"'modal-valign-' + (options?.verticalAlign || 'center')\">\n        <h3 class=\"modal-title\"><ng-container *ngTemplateOutlet=\"(titleTemplateRef$ | async)\"></ng-container></h3>\n        <div class=\"modal-body\">\n            <vdr-dialog-component-outlet [component]=\"childComponentType\"\n                (create)=\"onCreate($event)\"></vdr-dialog-component-outlet>\n        </div>\n        <div class=\"modal-footer\">\n            <ng-container *ngTemplateOutlet=\"(buttonsTemplateRef$ | async)\"></ng-container>\n        </div>\n    </clr-modal>\n</div>", styles: ["::ng-deep clr-modal.modal-valign-top .modal{justify-content:flex-start}::ng-deep clr-modal.modal-valign-bottom .modal{justify-content:flex-end}::ng-deep clr-modal .modal-dialog{display:flex}::ng-deep clr-modal .modal-content-wrapper{flex:1;display:flex}::ng-deep clr-modal .modal-dialog .modal-content{flex:1;display:flex;flex-direction:column}@media screen and (max-height: 700px){::ng-deep clr-modal .modal-dialog .modal-content{padding:.8rem}::ng-deep clr-modal .modal-header,::ng-deep clr-modal .modal-header--accessible{padding-bottom:.8rem}::ng-deep clr-modal .modal-footer{padding-top:.8rem}}.modal-body{display:flex;flex-direction:column;container-type:inline-size}\n"], dependencies: [{ kind: "component", type: i2.ClrModal, selector: "clr-modal", inputs: ["clrModalOpen", "clrModalClosable", "clrModalCloseButtonAriaLabel", "clrModalSize", "clrModalStaticBackdrop", "clrModalSkipAnimation", "clrModalPreventClose", "clrModalLabelledById"], outputs: ["clrModalOpenChange", "clrModalAlternateClose"] }, { kind: "directive", type: i2.ClrModalBody, selector: ".modal-body" }, { kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "component", type: i5.DialogComponentOutletComponent, selector: "vdr-dialog-component-outlet", inputs: ["component"], outputs: ["create"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: ModalDialogComponent, decorators: [{
            type: Component,
            args: [{ selector: 'vdr-modal-dialog', template: "<div [dir]=\"direction$ | async\">\n    <clr-modal [clrModalOpen]=\"true\" (clrModalOpenChange)=\"modalOpenChange($event)\"\n        [clrModalClosable]=\"options?.closable\" [clrModalSize]=\"options?.size\"\n        [ngClass]=\"'modal-valign-' + (options?.verticalAlign || 'center')\">\n        <h3 class=\"modal-title\"><ng-container *ngTemplateOutlet=\"(titleTemplateRef$ | async)\"></ng-container></h3>\n        <div class=\"modal-body\">\n            <vdr-dialog-component-outlet [component]=\"childComponentType\"\n                (create)=\"onCreate($event)\"></vdr-dialog-component-outlet>\n        </div>\n        <div class=\"modal-footer\">\n            <ng-container *ngTemplateOutlet=\"(buttonsTemplateRef$ | async)\"></ng-container>\n        </div>\n    </clr-modal>\n</div>", styles: ["::ng-deep clr-modal.modal-valign-top .modal{justify-content:flex-start}::ng-deep clr-modal.modal-valign-bottom .modal{justify-content:flex-end}::ng-deep clr-modal .modal-dialog{display:flex}::ng-deep clr-modal .modal-content-wrapper{flex:1;display:flex}::ng-deep clr-modal .modal-dialog .modal-content{flex:1;display:flex;flex-direction:column}@media screen and (max-height: 700px){::ng-deep clr-modal .modal-dialog .modal-content{padding:.8rem}::ng-deep clr-modal .modal-header,::ng-deep clr-modal .modal-header--accessible{padding-bottom:.8rem}::ng-deep clr-modal .modal-footer{padding-top:.8rem}}.modal-body{display:flex;flex-direction:column;container-type:inline-size}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.LocalizationService }]; } });
//# sourceMappingURL=data:application/json;base64, 