import { __decorate } from "tslib";
import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GlobalInjector } from '../../../../common/services/global-injector';
import { DropdownModule } from 'primeng/dropdown';
import { Select } from '@ngxs/store';
import { FormsModule } from '@angular/forms';
import { SharedModule } from 'primeng/api';
import { SmzResponsiveComponent } from '../../../smz-responsive/smz-responsive.component';
import { showSwitchLocalizationDialog } from './show-localization-switch-dialog';
import { UiLocalizationDbSelectors } from '../../../../state/database/ui-localization/ui-localization.selectors';
import { UiLocalizationDbActions } from '../../../../state/database/ui-localization/ui-localization.actions';
import * as i0 from "@angular/core";
import * as i1 from "@ngxs/store";
import * as i2 from "@angular/common";
import * as i3 from "primeng/dropdown";
import * as i4 from "primeng/api";
import * as i5 from "@angular/forms";
export class SmzLocalizationSwitchComponent {
    ngOnInit() {
        this.updateSelectionWithCurrent();
    }
    constructor(store) {
        this.store = store;
        this.showLocalizationSwitch = GlobalInjector.config.rbkUtils.uiLocalization.allowLocalizationSwitching;
    }
    onSelectorChange(locale) {
        this.store.dispatch(new UiLocalizationDbActions.SetCurrent(locale.code));
        setTimeout(() => this.updateSelectionWithCurrent(), 0);
    }
    updateSelectionWithCurrent() {
        this.selected = this.store.selectSnapshot(UiLocalizationDbSelectors.current);
    }
    showSwitchDialog() {
        showSwitchLocalizationDialog();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: SmzLocalizationSwitchComponent, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.5", type: SmzLocalizationSwitchComponent, isStandalone: true, selector: "smz-localization-switch", host: { classAttribute: "h-full relative" }, ngImport: i0, template: `
  <ng-container *ngIf="showLocalizationSwitch">

    <smz-responsive class="col grid grid-nogutter w-full items-center justify-start">

    <!-- LANDSCAPE -->
      <ng-template pTemplate="landscape">

        <div  class="h-full grid grid-nogutter items-center justify-center">
          <p-dropdown [options]="locales$ | async" styleClass="smz-tenant-switch-small" optionLabel="alias" dataKey="name" appendTo="body" [(ngModel)]="selected" (onChange)="onSelectorChange($event.value)">

            <ng-template pTemplate="selectedItem">
                <div class="flex align-items-center gap-2" *ngIf="selected">
                    <img src="https://primefaces.org/cdn/primeng/images/demo/flag/flag_placeholder.png" [class]="'flag flag-' + selected.country.toLowerCase()" style="width: 18px"/>
                    <div>{{ selected.name }}</div>
                </div>
            </ng-template>
            <ng-template let-locale pTemplate="item">
                <div class="flex align-items-center gap-2">
                    <img src="https://primefaces.org/cdn/primeng/images/demo/flag/flag_placeholder.png" [class]="'flag flag-' + locale.country.toLowerCase()" style="width: 18px"/>
                    <div>{{ locale.name }}</div>
                </div>
            </ng-template>

        </p-dropdown>

        </div>

      </ng-template>

      <!-- PORTRAIT -->
      <ng-template pTemplate="portrait">
        <i class="fa-solid fa-repeat cursor-pointer text-2xl text-text-color switch-tenant" (click)="showSwitchDialog()">
      </i>
      </ng-template>

    </smz-responsive>

  </ng-container>
  `, isInline: true, styles: [".smz-localization-switch-small .p-inputtext{padding:.5rem .75rem!important}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }, { kind: "ngmodule", type: DropdownModule }, { kind: "component", type: i3.Dropdown, selector: "p-dropdown", inputs: ["id", "scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "filterPlaceholder", "filterLocale", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "dropdownIcon", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "disabled", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterValue", "options"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { kind: "directive", type: i4.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: SharedModule }, { kind: "component", type: SmzResponsiveComponent, selector: "smz-responsive" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None }); }
}
__decorate([
    Select(UiLocalizationDbSelectors.locales)
], SmzLocalizationSwitchComponent.prototype, "locales$", void 0);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: SmzLocalizationSwitchComponent, decorators: [{
            type: Component,
            args: [{ selector: 'smz-localization-switch', standalone: true, imports: [CommonModule, DropdownModule, FormsModule, SharedModule, SmzResponsiveComponent], host: { class: 'h-full relative' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.Default, template: `
  <ng-container *ngIf="showLocalizationSwitch">

    <smz-responsive class="col grid grid-nogutter w-full items-center justify-start">

    <!-- LANDSCAPE -->
      <ng-template pTemplate="landscape">

        <div  class="h-full grid grid-nogutter items-center justify-center">
          <p-dropdown [options]="locales$ | async" styleClass="smz-tenant-switch-small" optionLabel="alias" dataKey="name" appendTo="body" [(ngModel)]="selected" (onChange)="onSelectorChange($event.value)">

            <ng-template pTemplate="selectedItem">
                <div class="flex align-items-center gap-2" *ngIf="selected">
                    <img src="https://primefaces.org/cdn/primeng/images/demo/flag/flag_placeholder.png" [class]="'flag flag-' + selected.country.toLowerCase()" style="width: 18px"/>
                    <div>{{ selected.name }}</div>
                </div>
            </ng-template>
            <ng-template let-locale pTemplate="item">
                <div class="flex align-items-center gap-2">
                    <img src="https://primefaces.org/cdn/primeng/images/demo/flag/flag_placeholder.png" [class]="'flag flag-' + locale.country.toLowerCase()" style="width: 18px"/>
                    <div>{{ locale.name }}</div>
                </div>
            </ng-template>

        </p-dropdown>

        </div>

      </ng-template>

      <!-- PORTRAIT -->
      <ng-template pTemplate="portrait">
        <i class="fa-solid fa-repeat cursor-pointer text-2xl text-text-color switch-tenant" (click)="showSwitchDialog()">
      </i>
      </ng-template>

    </smz-responsive>

  </ng-container>
  `, styles: [".smz-localization-switch-small .p-inputtext{padding:.5rem .75rem!important}\n"] }]
        }], ctorParameters: () => [{ type: i1.Store }], propDecorators: { locales$: [] } });
//# sourceMappingURL=data:application/json;base64, 