import { Component, Input } from '@angular/core';
import { UntypedFormControl } from '@angular/forms';
import { TranslateService } from '@aztrix/translate';
import { Subscription } from 'rxjs';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/translate";
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGFuZ3VhZ2Utc2VsZWN0LmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvY29tcG9uZW50cy9sYW5ndWFnZS1zZWxlY3QvbGFuZ3VhZ2Utc2VsZWN0LmNvbXBvbmVudC50cyIsIi4uLy4uLy4uLy4uLy4uL2xpYnMvY29tcG9uZW50cy9sYW5ndWFnZS1zZWxlY3QvbGFuZ3VhZ2Utc2VsZWN0LmNvbXBvbmVudC5odG1sIl0sIm5hbWVzIjpbXSwibW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