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 { ACCORDION_TRANSITION_NAME } from '../../component-names';
import WithRender from './accordion-transition.html';
import './accordion-transition.scss';
var CLASS_HAS_TRANSITION = 'm--has-transition';
var MAccordionTransition = /** @class */ (function (_super) {
    __extends(MAccordionTransition, _super);
    function MAccordionTransition() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MAccordionTransition.prototype.setClassHasTransition = function (el) {
        if (!el.classList.contains(ACCORDION_TRANSITION_NAME)) {
            el.classList.add(ACCORDION_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);
        }
    };
    MAccordionTransition.prototype.beforeEnter = function (el) {
        this.setClassHasTransition(el);
    };
    MAccordionTransition.prototype.enter = function (el, done) {
        var heightDelta = this.heightDelta || 0;
        el.style.height = el.scrollHeight - heightDelta + "px";
    };
    MAccordionTransition.prototype.afterEnter = function (el) {
        el.style.removeProperty('height');
    };
    MAccordionTransition.prototype.enterCancelled = function (el) {
        el.style.removeProperty('height');
    };
    MAccordionTransition.prototype.beforeLeave = function (el) {
        el.style.height = parseInt(window.getComputedStyle(el).height, 10) + 'px';
        this.setClassHasTransition(el);
    };
    MAccordionTransition.prototype.leave = function (el, done) { };
    MAccordionTransition.prototype.afterLeave = function (el) {
        el.style.removeProperty('height');
    };
    MAccordionTransition.prototype.leaveCancelled = function (el) {
        el.style.removeProperty('height');
    };
    __decorate([
        Prop()
    ], MAccordionTransition.prototype, "heightDelta", void 0);
    __decorate([
        Prop({ default: false })
    ], MAccordionTransition.prototype, "disabled", void 0);
    __decorate([
        Emit('before-enter')
    ], MAccordionTransition.prototype, "beforeEnter", null);
    __decorate([
        Emit('enter')
    ], MAccordionTransition.prototype, "enter", null);
    __decorate([
        Emit('after-enter')
    ], MAccordionTransition.prototype, "afterEnter", null);
    __decorate([
        Emit('enter-cancelled')
    ], MAccordionTransition.prototype, "enterCancelled", null);
    __decorate([
        Emit('before-leave')
    ], MAccordionTransition.prototype, "beforeLeave", null);
    __decorate([
        Emit('leave')
    ], MAccordionTransition.prototype, "leave", null);
    __decorate([
        Emit('after-leave')
    ], MAccordionTransition.prototype, "afterLeave", null);
    __decorate([
        Emit('leave-cancelled')
    ], MAccordionTransition.prototype, "leaveCancelled", null);
    MAccordionTransition = __decorate([
        WithRender,
        Component
    ], MAccordionTransition);
    return MAccordionTransition;
}(ModulVue));
export { MAccordionTransition };
var AccordionTransitionPlugin = {
    install: function (v, options) {
        v.component(ACCORDION_TRANSITION_NAME, MAccordionTransition);
    }
};
export default AccordionTransitionPlugin;
//# sourceMappingURL=accordion-transition.js.map