import { Injectable } from '@angular/core';
import { App } from '../app/app';
import { isPresent } from '../../util/util';
import { ModalCmp } from './modal-component';
import { ViewController } from '../../navigation/view-controller';
export class Modal extends ViewController {
    constructor(app, component, data, opts = {}) {
        data = data || {};
        data.component = component;
        opts.showBackdrop = isPresent(opts.showBackdrop) ? !!opts.showBackdrop : true;
        opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
        data.opts = opts;
        super(ModalCmp, data, null);
        this._app = app;
        this._enterAnimation = opts.enterAnimation;
        this._leaveAnimation = opts.leaveAnimation;
        this.isOverlay = true;
    }
    getTransitionName(direction) {
        let key;
        if (direction === 'back') {
            if (this._leaveAnimation) {
                return this._leaveAnimation;
            }
            key = 'modalLeave';
        }
        else {
            if (this._enterAnimation) {
                return this._enterAnimation;
            }
            key = 'modalEnter';
        }
        return this._nav && this._nav.config.get(key);
    }
    present(navOptions = {}) {
        return this._app.present(this, navOptions, 1);
    }
}
export class ModalController {
    constructor(_app) {
        this._app = _app;
    }
    create(component, data = {}, opts = {}) {
        return new Modal(this._app, component, data, opts);
    }
}
ModalController.decorators = [
    { type: Injectable },
];
ModalController.ctorParameters = [
    { type: App, },
];
//# sourceMappingURL=modal.js.map