import { Component, Input } from '@angular/core';
import { UntypedFormControl } from '@angular/forms';
import { TranslateService } from '@aztrix/helpers';
import { Subscription } from 'rxjs';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/helpers";
import * as i2 from "@angular/common";
import * as i3 from "@angular/material/legacy-select";
import * as i4 from "@angular/material/legacy-core";
import * as i5 from "@angular/forms";
export class LanguageSelectComponent {
    constructor(_translate) {
        this._translate = _translate;
        this.langs = this._translate.getLangs();
        this.selectedForm = new UntypedFormControl({
            value: 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
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGFuZ3VhZ2Utc2VsZWN0LmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvY29tcG9uZW50cy9sYW5ndWFnZS1zZWxlY3QvbGFuZ3VhZ2Utc2VsZWN0LmNvbXBvbmVudC50cyIsIi4uLy4uLy4uLy4uLy4uL2xpYnMvY29tcG9uZW50cy9sYW5ndWFnZS1zZWxlY3QvbGFuZ3VhZ2Utc2VsZWN0LmNvbXBvbmVudC5odG1sIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBQyxTQUFTLEVBQUUsS0FBSyxFQUFvQixNQUFNLGVBQWUsQ0FBQztBQUNsRSxPQUFPLEVBQUMsa0JBQWtCLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUNsRCxPQUFPLEVBQUMsZ0JBQWdCLEVBQUMsTUFBTSxpQkFBaUIsQ0FBQztBQUNqRCxPQUFPLEVBQUMsWUFBWSxFQUFDLE1BQU0sTUFBTSxDQUFDOz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