<!--

    Copyright © 2016-2023 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.

-->
<ng-container [formGroup]="rangeChartWidgetSettingsForm">
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widgets.range-chart.range-chart-card-style</div>
    <div class="tb-form-row">
      <mat-slide-toggle class="mat-slide" formControlName="dataZoom">
        {{ 'widgets.range-chart.data-zoom' | translate }}
      </mat-slide-toggle>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.range-chart.range-colors' | translate }}</div>
      <tb-color-range-settings formControlName="rangeColors">
      </tb-color-range-settings>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.range-chart.out-of-range-color' | translate }}</div>
      <tb-color-input asBoxInput
                      colorClearButton
                      formControlName="outOfRangeColor">
      </tb-color-input>
    </div>
    <div class="tb-form-row">
      <mat-slide-toggle class="mat-slide" formControlName="fillArea">
        {{ 'widgets.range-chart.fill-area' | translate }}
      </mat-slide-toggle>
    </div>
    <div class="tb-form-panel tb-slide-toggle">
      <mat-expansion-panel class="tb-settings" [expanded]="rangeChartWidgetSettingsForm.get('showLegend').value" [disabled]="!rangeChartWidgetSettingsForm.get('showLegend').value">
        <mat-expansion-panel-header fxLayout="row wrap">
          <mat-panel-title>
            <mat-slide-toggle class="mat-slide" formControlName="showLegend" (click)="$event.stopPropagation()"
                              fxLayoutAlign="center">
              {{ 'widget-config.legend' | translate }}
            </mat-slide-toggle>
          </mat-panel-title>
        </mat-expansion-panel-header>
        <ng-template matExpansionPanelContent>
          <div class="tb-form-row space-between">
            <div>{{ 'legend.position' | translate }}</div>
            <mat-form-field class="medium-width" appearance="outline" subscriptSizing="dynamic">
              <mat-select formControlName="legendPosition">
                <mat-option *ngFor="let pos of legendPositions" [value]="pos">
                  {{ legendPositionTranslationMap.get(pos) | translate }}
                </mat-option>
              </mat-select>
            </mat-form-field>
          </div>
          <div class="tb-form-row space-between">
            <div>{{ 'widgets.range-chart.legend-label' | translate }}</div>
            <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
              <tb-font-settings formControlName="legendLabelFont"
                                previewText="20 - 30">
              </tb-font-settings>
              <tb-color-input asBoxInput
                              colorClearButton
                              formControlName="legendLabelColor">
              </tb-color-input>
            </div>
          </div>
        </ng-template>
      </mat-expansion-panel>
    </div>
    <div class="tb-form-panel tb-slide-toggle">
      <mat-expansion-panel class="tb-settings" [expanded]="rangeChartWidgetSettingsForm.get('showTooltip').value" [disabled]="!rangeChartWidgetSettingsForm.get('showTooltip').value">
        <mat-expansion-panel-header fxLayout="row wrap">
          <mat-panel-title>
            <mat-slide-toggle class="mat-slide" formControlName="showTooltip" (click)="$event.stopPropagation()"
                              fxLayoutAlign="center">
              {{ 'widgets.range-chart.tooltip' | translate }}
            </mat-slide-toggle>
          </mat-panel-title>
        </mat-expansion-panel-header>
        <ng-template matExpansionPanelContent>
          <div class="tb-form-row space-between">
            <div>{{ 'widgets.range-chart.tooltip-value' | translate }}</div>
            <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
              <tb-font-settings formControlName="tooltipValueFont"
                                [previewText]="tooltipValuePreviewFn">
              </tb-font-settings>
              <tb-color-input asBoxInput
                              colorClearButton
                              formControlName="tooltipValueColor">
              </tb-color-input>
            </div>
          </div>
          <div class="tb-form-row column-xs">
            <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="tooltipShowDate">
              {{ 'widgets.range-chart.tooltip-date' | translate }}
            </mat-slide-toggle>
            <div fxFlex.gt-xs fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
              <tb-date-format-select fxFlex excludeLastUpdateAgo formControlName="tooltipDateFormat"></tb-date-format-select>
              <tb-font-settings formControlName="tooltipDateFont"
                                [previewText]="tooltipDatePreviewFn">
              </tb-font-settings>
              <tb-color-input asBoxInput
                              colorClearButton
                              formControlName="tooltipDateColor">
              </tb-color-input>
            </div>
          </div>
          <div class="tb-form-row space-between">
            <div>{{ 'widgets.range-chart.tooltip-background-color' | translate }}</div>
            <tb-color-input asBoxInput
                            colorClearButton
                            formControlName="tooltipBackgroundColor">
            </tb-color-input>
          </div>
          <div class="tb-form-row space-between">
            <div>{{ 'widgets.range-chart.tooltip-background-blur' | translate }}</div>
            <mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
              <input matInput formControlName="tooltipBackgroundBlur" type="number" min="0" step="1" placeholder="{{ 'widget-config.set' | translate }}">
              <div matSuffix>px</div>
            </mat-form-field>
          </div>
        </ng-template>
      </mat-expansion-panel>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.background.background' | translate }}</div>
      <tb-background-settings formControlName="background">
      </tb-background-settings>
    </div>
  </div>
</ng-container>
