import * as i0 from '@angular/core';
import { input, computed, Component, NgModule } from '@angular/core';
import { t, injectSiTranslateService, SiTranslatePipe } from '@siemens/element-translate-ng/translate';

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
class SiLanguageSwitcherComponent {
    /**
     * Key for translation.
     * If the key is set to an empty string, the language of the underlying translation framework will not be switched.
     *
     * @defaultValue 'LANGUAGE'
     */
    translationKey = input('LANGUAGE', ...(ngDevMode ? [{ debugName: "translationKey" }] : []));
    /**
     * Text for aria label for the language selector. Needed for a11y
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_LANGUAGE_SWITCHER.LABEL:Language switcher`)
     * ```
     */
    languageSwitcherLabel = input(t(() => $localize `:@@SI_LANGUAGE_SWITCHER.LABEL:Language switcher`), ...(ngDevMode ? [{ debugName: "languageSwitcherLabel" }] : []));
    /**
     * List of all available languages in this application.
     *
     * @defaultValue null
     */
    availableLanguages = input(null, ...(ngDevMode ? [{ debugName: "availableLanguages" }] : []));
    translate = injectSiTranslateService();
    availableIsoLanguages = computed(() => {
        let languages = this.availableLanguages() ?? this.translate.availableLanguages;
        if (typeof languages[0] !== 'object') {
            languages = languages.map(languageValue => {
                const translationKey = this.translationKey();
                return {
                    value: languageValue,
                    name: translationKey ? `${translationKey}.${languageValue.toUpperCase()}` : languageValue
                };
            });
        }
        return languages;
    }, ...(ngDevMode ? [{ debugName: "availableIsoLanguages" }] : []));
    switchLanguage(target) {
        const language = target?.value;
        const translationKey = this.translationKey();
        if (!language || !translationKey?.length) {
            return;
        }
        this.translate.setCurrentLanguage(language);
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiLanguageSwitcherComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.8", type: SiLanguageSwitcherComponent, isStandalone: true, selector: "si-language-switcher", inputs: { translationKey: { classPropertyName: "translationKey", publicName: "translationKey", isSignal: true, isRequired: false, transformFunction: null }, languageSwitcherLabel: { classPropertyName: "languageSwitcherLabel", publicName: "languageSwitcherLabel", isSignal: true, isRequired: false, transformFunction: null }, availableLanguages: { classPropertyName: "availableLanguages", publicName: "availableLanguages", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<select\n  class=\"si-h5 language-switcher-select\"\n  [attr.aria-label]=\"languageSwitcherLabel() | translate\"\n  (change)=\"switchLanguage($event.target)\"\n>\n  @for (language of availableIsoLanguages(); track language.value) {\n    <option [value]=\"language.value\" [selected]=\"language.value === translate.currentLanguage\">\n      {{ language.name | translate }}\n    </option>\n  }\n</select>\n", styles: [":host{--language-switcher-color: var(--element-text-active)}.language-switcher-select{inline-size:100%;background-color:transparent;border:0;border-block-end:1px solid var(--input-border-color);padding:6px;cursor:pointer;color:var(--language-switcher-color)}@media(min-width:768px){.language-switcher-select{max-inline-size:200px}}.language-switcher-select option{background-color:var(--element-base-1)}\n"], dependencies: [{ kind: "pipe", type: SiTranslatePipe, name: "translate" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiLanguageSwitcherComponent, decorators: [{
            type: Component,
            args: [{ selector: 'si-language-switcher', imports: [SiTranslatePipe], template: "<select\n  class=\"si-h5 language-switcher-select\"\n  [attr.aria-label]=\"languageSwitcherLabel() | translate\"\n  (change)=\"switchLanguage($event.target)\"\n>\n  @for (language of availableIsoLanguages(); track language.value) {\n    <option [value]=\"language.value\" [selected]=\"language.value === translate.currentLanguage\">\n      {{ language.name | translate }}\n    </option>\n  }\n</select>\n", styles: [":host{--language-switcher-color: var(--element-text-active)}.language-switcher-select{inline-size:100%;background-color:transparent;border:0;border-block-end:1px solid var(--input-border-color);padding:6px;cursor:pointer;color:var(--language-switcher-color)}@media(min-width:768px){.language-switcher-select{max-inline-size:200px}}.language-switcher-select option{background-color:var(--element-base-1)}\n"] }]
        }], propDecorators: { translationKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "translationKey", required: false }] }], languageSwitcherLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "languageSwitcherLabel", required: false }] }], availableLanguages: [{ type: i0.Input, args: [{ isSignal: true, alias: "availableLanguages", required: false }] }] } });

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
class SiLanguageSwitcherModule {
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiLanguageSwitcherModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
    static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.8", ngImport: i0, type: SiLanguageSwitcherModule, imports: [SiLanguageSwitcherComponent], exports: [SiLanguageSwitcherComponent] });
    static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiLanguageSwitcherModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiLanguageSwitcherModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [SiLanguageSwitcherComponent],
                    exports: [SiLanguageSwitcherComponent]
                }]
        }] });

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */

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

export { SiLanguageSwitcherComponent, SiLanguageSwitcherModule };
//# sourceMappingURL=siemens-element-ng-language-switcher.mjs.map
