<!--

    Copyright © 2016-2026 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="date-range-navigator"
     [class.short-mode]="ctx.width < 400"
     [class.labels-hidden]="settings.hideLabels"
     [class.long-mode]="ctx.width >= 400">
  <mat-form-field class="mat-block" [class.!hidden]="settings.hidePicker" (click)="openNavigatorPanel($event)" appearance="outline">
    @if (!settings.hideLabels) {
      <mat-label translate>widgets.date-range-navigator.localizationMap.Date picker</mat-label>
    }
    <mat-select #datePicker [ngModel]="advancedModel.chosenLabel">
      <mat-option [value]="advancedModel.chosenLabel">
        {{advancedModel.chosenLabel}}
      </mat-option>
    </mat-select>
  </mat-form-field>
  <mat-form-field class="mat-block" [class.!hidden]="settings.hideInterval" appearance="outline">
    @if (!settings.hideLabels) {
      <mat-label translate>widgets.date-range-navigator.localizationMap.Interval</mat-label>
    }
    <mat-select [(ngModel)]="selectedDateInterval" (ngModelChange)="changeInterval()">
      @if (customInterval) {
        <mat-option [value]="customInterval.ts">
          {{'widgets.date-range-navigator.localizationMap.' + customInterval.label | translate}}
        </mat-option>
      }
      @for (date of datesMap | keyvalue: originalOrder; track date) {
        <mat-option [value]="date.value.ts">
          {{'widgets.date-range-navigator.localizationMap.' + date.value.label | translate}}
        </mat-option>
      }
    </mat-select>
  </mat-form-field>

  <div class="drn__element step" [class.!hidden]="settings.hideStepSize">
    <button mat-icon-button (click)="goBack()">
      <mat-icon>keyboard_arrow_left</mat-icon>
    </button>
    <mat-form-field class="mat-block gt-sm:flex-1" appearance="outline">
      @if (!settings.hideLabels) {
        <mat-label translate>widgets.date-range-navigator.localizationMap.Step size</mat-label>
      }
      <mat-select [(ngModel)]="selectedStepSize">
        @for (date of datesMap | keyvalue: originalOrder; track date) {
          <mat-option [value]="date.value.ts">
            {{'widgets.date-range-navigator.localizationMap.' + date.value.label | translate}}
          </mat-option>
        }
      </mat-select>
    </mat-form-field>
    <button mat-icon-button (click)="goForth()">
      <mat-icon>keyboard_arrow_right</mat-icon>
    </button>
  </div>
</div>
