import * as i0 from '@angular/core';
import { Component, Input, NgModule } from '@angular/core';
import * as i5 from '@angular/forms';
import { UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
import { Subscription } from 'rxjs';
import * as i1 from '@aztrix/helpers';
import * as i2 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i3 from '@angular/material/legacy-select';
import { MatLegacySelectModule } from '@angular/material/legacy-select';
import * as i4 from '@angular/material/legacy-core';

class LanguageSelectComponent {
    constructor(_translate) {
        this._translate = _translate;
        this.langs = this._translate.getLangs();
        this.selectedForm = new UntypedFormControl(this._translate.getActiveLang() || this._translate.getDefaultLang());
        this.subscription = new Subscription();
    }
    ngOnInit() {
        this.subscription = this.selectedForm.valueChanges.subscribe((lang) => {
            this._translate.setActiveLang(lang);
        });
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
}
LanguageSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: LanguageSelectComponent, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
LanguageSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: LanguageSelectComponent, selector: "ax-language-select", inputs: { langs: "langs" }, ngImport: i0, template: "<mat-select [formControl]=\"selectedForm\" *ngIf=\"langs?.length > 1\">\n  <mat-option *ngFor=\"let lang of langs\" [value]=\"lang\"> {{ lang | uppercase }}</mat-option>\n</mat-select>\n", styles: [":host{display:block;width:3rem}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatLegacySelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i4.MatLegacyOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "directive", type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "pipe", type: i2.UpperCasePipe, name: "uppercase" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: LanguageSelectComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-language-select', template: "<mat-select [formControl]=\"selectedForm\" *ngIf=\"langs?.length > 1\">\n  <mat-option *ngFor=\"let lang of langs\" [value]=\"lang\"> {{ lang | uppercase }}</mat-option>\n</mat-select>\n", styles: [":host{display:block;width:3rem}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.TranslateService }]; }, propDecorators: { langs: [{
                type: Input
            }] } });

class LanguageSelectModule {
}
LanguageSelectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: LanguageSelectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
LanguageSelectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.5", ngImport: i0, type: LanguageSelectModule, declarations: [LanguageSelectComponent], imports: [CommonModule, MatLegacySelectModule, ReactiveFormsModule], exports: [LanguageSelectComponent] });
LanguageSelectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: LanguageSelectModule, imports: [CommonModule, MatLegacySelectModule, ReactiveFormsModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: LanguageSelectModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [LanguageSelectComponent],
                    imports: [CommonModule, MatLegacySelectModule, ReactiveFormsModule],
                    exports: [LanguageSelectComponent],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { LanguageSelectComponent, LanguageSelectModule };
//# sourceMappingURL=aztrix-components-language-select.mjs.map
//# sourceMappingURL=aztrix-components-language-select.mjs.map
