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/select";
import * as i4 from "@angular/material/core";
import * as i5 from "@angular/forms";
export 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();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LanguageSelectComponent, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: LanguageSelectComponent, selector: "ax-language-select", inputs: { langs: "langs" }, ngImport: i0, template: "<mat-select [formControl]=\"selectedForm\" *ngIf=\"(langs?.length || 0) > 1\" [panelWidth]=\"null\">\n  <mat-option *ngFor=\"let lang of langs\" [value]=\"lang\"> {{ lang | uppercase }}</mat-option>\n</mat-select>\n", styles: [":host{display:block;width:3rem;--mat-select-enabled-arrow-color: white;--mat-select-enabled-trigger-text-color: white}\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.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], 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: "17.3.12", ngImport: i0, type: LanguageSelectComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-language-select', template: "<mat-select [formControl]=\"selectedForm\" *ngIf=\"(langs?.length || 0) > 1\" [panelWidth]=\"null\">\n  <mat-option *ngFor=\"let lang of langs\" [value]=\"lang\"> {{ lang | uppercase }}</mat-option>\n</mat-select>\n", styles: [":host{display:block;width:3rem;--mat-select-enabled-arrow-color: white;--mat-select-enabled-trigger-text-color: white}\n"] }]
        }], ctorParameters: () => [{ type: i1.TranslateService }], propDecorators: { langs: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGFuZ3VhZ2Utc2VsZWN0LmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvY29tcG9uZW50cy9sYW5ndWFnZS1zZWxlY3QvbGFuZ3VhZ2Utc2VsZWN0LmNvbXBvbmVudC50cyIsIi4uLy4uLy4uLy4uLy4uL2xpYnMvY29tcG9uZW50cy9sYW5ndWFnZS1zZWxlY3QvbGFuZ3VhZ2Utc2VsZWN0LmNvbXBvbmVudC5odG1sIl0sIm5hbWVzIjpbXSw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