import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Emit, Prop } from 'vue-property-decorator';
import { ModulVue } from '../../../utils/vue/vue';
import { OPACITY_TRANSITION_NAME } from '../../component-names';
import WithRender from './opacity-transition.html?style=./opacity-transition.scss';
var CLASS_HAS_TRANSITION = 'm--has-transition';
var CLASS_HAS_ZOOM_EFFECT = 'm--has-zoom-effect';
var MOpacityTransition = /** @class */ (function (_super) {
    __extends(MOpacityTransition, _super);
    function MOpacityTransition() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MOpacityTransition.prototype.setClassOfTransition = function (el) {
        if (!el.classList.contains(OPACITY_TRANSITION_NAME)) {
            el.classList.add(OPACITY_TRANSITION_NAME);
        }
        if (!this.disabled) {
            if (!el.classList.contains(CLASS_HAS_TRANSITION)) {
                el.classList.add(CLASS_HAS_TRANSITION);
            }
        }
        else if (el.classList.contains(CLASS_HAS_TRANSITION)) {
            el.classList.remove(CLASS_HAS_TRANSITION);
        }
        if (this.zoomEffect && !this.disabled) {
            if (!el.classList.contains(CLASS_HAS_ZOOM_EFFECT)) {
                el.classList.add(CLASS_HAS_ZOOM_EFFECT);
            }
        }
        else if (el.classList.contains(CLASS_HAS_ZOOM_EFFECT)) {
            el.classList.remove(CLASS_HAS_ZOOM_EFFECT);
        }
    };
    MOpacityTransition.prototype.beforeEnter = function (el) {
        this.setClassOfTransition(el);
    };
    MOpacityTransition.prototype.enter = function (el, done) { };
    MOpacityTransition.prototype.afterEnter = function (el) { };
    MOpacityTransition.prototype.enterCancelled = function (el) { };
    MOpacityTransition.prototype.beforeLeave = function (el) {
        this.setClassOfTransition(el);
    };
    MOpacityTransition.prototype.leave = function (el, done) { };
    MOpacityTransition.prototype.afterLeave = function (el) { };
    MOpacityTransition.prototype.leaveCancelled = function (el) { };
    __decorate([
        Prop({ default: false })
    ], MOpacityTransition.prototype, "disabled", void 0);
    __decorate([
        Prop({ default: true })
    ], MOpacityTransition.prototype, "zoomEffect", void 0);
    __decorate([
        Emit('before-enter')
    ], MOpacityTransition.prototype, "beforeEnter", null);
    __decorate([
        Emit('enter')
    ], MOpacityTransition.prototype, "enter", null);
    __decorate([
        Emit('after-enter')
    ], MOpacityTransition.prototype, "afterEnter", null);
    __decorate([
        Emit('enter-cancelled')
    ], MOpacityTransition.prototype, "enterCancelled", null);
    __decorate([
        Emit('before-leave')
    ], MOpacityTransition.prototype, "beforeLeave", null);
    __decorate([
        Emit('leave')
    ], MOpacityTransition.prototype, "leave", null);
    __decorate([
        Emit('after-leave')
    ], MOpacityTransition.prototype, "afterLeave", null);
    __decorate([
        Emit('leave-cancelled')
    ], MOpacityTransition.prototype, "leaveCancelled", null);
    MOpacityTransition = __decorate([
        WithRender,
        Component
    ], MOpacityTransition);
    return MOpacityTransition;
}(ModulVue));
export { MOpacityTransition };
var OpacityTransitionPlugin = {
    install: function (v, options) {
        v.component(OPACITY_TRANSITION_NAME, MOpacityTransition);
    }
};
export default OpacityTransitionPlugin;
//# sourceMappingURL=opacity-transition.js.map