import { Directive, Input, Host, TemplateRef, ViewContainerRef } from '@angular/core';
import { NgSwitch } from '@angular/common';
export class ZUISwitchCasesDirective {
    constructor(viewContainer, templateRef, ngSwitch) {
        this.viewContainer = viewContainer;
        this.templateRef = templateRef;
        this._created = false;
        this.ngSwitch = ngSwitch;
    }
    ngOnInit() {
        var _a;
        const switchCase = (_a = this.zuiSwitchCases) !== null && _a !== void 0 ? _a : [];
        switchCase.forEach(() => this.ngSwitch._addCase());
    }
    ngDoCheck() {
        var _a;
        let enforce = false;
        ((_a = this.zuiSwitchCases) !== null && _a !== void 0 ? _a : []).forEach(value => (enforce = this.ngSwitch._matchCase(value) || enforce));
        this.enforceState(enforce);
    }
    enforceState(created) {
        if (created && !this._created) {
            this._created = true;
            this.viewContainer.createEmbeddedView(this.templateRef);
        }
        else if (!created && this._created) {
            this._created = false;
            this.viewContainer.clear();
        }
    }
}
ZUISwitchCasesDirective.decorators = [
    { type: Directive, args: [{
                selector: '[zuiSwitchCases]',
            },] }
];
ZUISwitchCasesDirective.ctorParameters = () => [
    { type: ViewContainerRef },
    { type: TemplateRef },
    { type: NgSwitch, decorators: [{ type: Host }] }
];
ZUISwitchCasesDirective.propDecorators = {
    zuiSwitchCases: [{ type: Input }]
};
//# sourceMappingURL=zui-switch-case.directive.js.map