<!--

    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.

-->
<ng-container [formGroup]="lineSettingsFormGroup">
  @if (chartType !== TimeSeriesChartType.point) {
    <div class="tb-form-panel stroked">
      <div class="tb-form-panel-title" translate>widgets.time-series-chart.series.line.line</div>
      @if (chartType !== TimeSeriesChartType.state) {
        <div class="tb-form-row">
          <mat-slide-toggle class="mat-slide" formControlName="showLine">
            {{ 'widgets.time-series-chart.series.line.show-line' | translate }}
          </mat-slide-toggle>
        </div>
      }
      <div class="tb-form-row space-between column-xs">
        <mat-slide-toggle class="mat-slide" formControlName="step">
          {{ 'widgets.time-series-chart.series.line.step-line' | translate }}
        </mat-slide-toggle>
        <mat-form-field class="medium-width" appearance="outline" subscriptSizing="dynamic">
          <mat-select formControlName="stepType">
            @for (stepType of lineSeriesStepTypes; track stepType) {
              <mat-option [value]="stepType">
                {{ lineSeriesStepTypeTranslations.get(stepType) | translate }}
              </mat-option>
            }
          </mat-select>
        </mat-form-field>
      </div>
      @if (chartType !== TimeSeriesChartType.state) {
        <div class="tb-form-row">
          <mat-slide-toggle class="mat-slide" formControlName="smooth">
            {{ 'widgets.time-series-chart.series.line.smooth-line' | translate }}
          </mat-slide-toggle>
        </div>
      }
      <div class="tb-form-row space-between column-xs">
        <div translate>widgets.time-series-chart.line-type</div>
        <mat-form-field class="medium-width" appearance="outline" subscriptSizing="dynamic">
          <mat-select formControlName="lineType">
            @for (lineType of chartLineTypes; track lineType) {
              <mat-option [value]="lineType">
                {{ chartLineTypeTranslations.get(lineType) | translate }}
              </mat-option>
            }
          </mat-select>
        </mat-form-field>
      </div>
      <div class="tb-form-row space-between column-xs">
        <div translate>widgets.time-series-chart.line-width</div>
        <mat-form-field class="medium-width number" appearance="outline" subscriptSizing="dynamic">
          <input matInput type="number" formControlName="lineWidth" min="0" step="1" placeholder="{{ 'widget-config.set' | translate }}"/>
        </mat-form-field>
      </div>
    </div>
  }
  @if (chartType !== TimeSeriesChartType.point) {
    <div class="tb-form-panel stroked">
      <div class="tb-form-panel-title" translate>widgets.time-series-chart.series.point.points</div>
      <div class="tb-form-row">
        <mat-slide-toggle class="mat-slide" formControlName="showPoints">
          {{ 'widgets.time-series-chart.series.point.show-points' | translate }}
        </mat-slide-toggle>
      </div>
      <ng-container *ngTemplateOutlet="pointSettings"></ng-container>
    </div>
  } @else {
    <div class="tb-form-row space-between column-lt-md">
      <mat-slide-toggle class="mat-slide" formControlName="showPointLabel">
        <div tb-hint-tooltip-icon="{{'widgets.time-series-chart.series.point.point-label-hint' | translate}}">
          {{ 'widgets.time-series-chart.series.point.point-label' | translate }}
        </div>
      </mat-slide-toggle>
      <div class="flex flex-row items-center justify-start gap-2 lt-md:flex-1">
        <mat-form-field class="medium-width lt-md:flex-1" appearance="outline" subscriptSizing="dynamic">
          <mat-select formControlName="pointLabelPosition">
            @for (position of chartLabelPositions; track position) {
              <mat-option [value]="position">
                {{ chartLabelPositionTranslations.get(position) | translate }}
              </mat-option>
            }
          </mat-select>
        </mat-form-field>
        <tb-font-settings formControlName="pointLabelFont"
                          clearButton
                          disabledLineHeight
                          forceSizeUnit="px"
                          [previewText]="pointLabelPreviewFn">
        </tb-font-settings>
        <tb-color-input asBoxInput
                        colorClearButton
                        formControlName="pointLabelColor">
        </tb-color-input>
      </div>
    </div>
    <div class="tb-form-row space-between">
      <mat-slide-toggle class="mat-slide" formControlName="enablePointLabelBackground">
        {{ 'widgets.time-series-chart.series.point.point-label-background' | translate }}
      </mat-slide-toggle>
      <tb-color-input asBoxInput
                      colorClearButton
                      formControlName="pointLabelBackground">
      </tb-color-input>
    </div>
    <div class="tb-form-row space-between column-xs">
      <div translate>widgets.time-series-chart.series.point.point-shape</div>
      <mat-form-field class="medium-width" appearance="outline" subscriptSizing="dynamic">
        <mat-select formControlName="pointShape">
          @for (shape of chartShapes; track shape) {
            <mat-option [value]="shape">
              {{ chartShapeTranslations.get(shape) | translate }}
            </mat-option>
          }
        </mat-select>
      </mat-form-field>
    </div>
    <div class="tb-form-row space-between column-xs">
      <div translate>widgets.time-series-chart.series.point.point-size</div>
      <mat-form-field class="medium-width number" appearance="outline" subscriptSizing="dynamic">
        <input matInput type="number" formControlName="pointSize" min="0" step="1" placeholder="{{ 'widget-config.set' | translate }}"/>
      </mat-form-field>
    </div>
  }
  <tb-chart-fill-settings
    formControlName="fillAreaSettings">
  </tb-chart-fill-settings>
</ng-container>
<ng-template #pointSettings [formGroup]="lineSettingsFormGroup">
  <div class="tb-form-row space-between column-lt-md">
    <mat-slide-toggle class="mat-slide" formControlName="showPointLabel">
      <div tb-hint-tooltip-icon="{{'widgets.time-series-chart.series.point.point-label-hint' | translate}}">
        {{ 'widgets.time-series-chart.series.point.point-label' | translate }}
      </div>
    </mat-slide-toggle>
    <div class="flex flex-row items-center justify-start gap-2 lt-md:flex-1">
      <mat-form-field class="medium-width lt-md:flex-1" appearance="outline" subscriptSizing="dynamic">
        <mat-select formControlName="pointLabelPosition">
          @for (position of chartLabelPositions; track position) {
            <mat-option [value]="position">
              {{ chartLabelPositionTranslations.get(position) | translate }}
            </mat-option>
          }
        </mat-select>
      </mat-form-field>
      <tb-font-settings formControlName="pointLabelFont"
                        clearButton
                        disabledLineHeight
                        forceSizeUnit="px"
                        [previewText]="pointLabelPreviewFn">
      </tb-font-settings>
      <tb-color-input asBoxInput
                      colorClearButton
                      formControlName="pointLabelColor">
      </tb-color-input>
    </div>
  </div>
  <div class="tb-form-row space-between">
    <mat-slide-toggle class="mat-slide" formControlName="enablePointLabelBackground">
      {{ 'widgets.time-series-chart.series.point.point-label-background' | translate }}
    </mat-slide-toggle>
    <tb-color-input asBoxInput
                    colorClearButton
                    formControlName="pointLabelBackground">
    </tb-color-input>
  </div>
  <div class="tb-form-row space-between column-xs">
    <div translate>widgets.time-series-chart.series.point.point-shape</div>
    <mat-form-field class="medium-width" appearance="outline" subscriptSizing="dynamic">
      <mat-select formControlName="pointShape">
        @for (shape of chartShapes; track shape) {
          <mat-option [value]="shape">
            {{ chartShapeTranslations.get(shape) | translate }}
          </mat-option>
        }
      </mat-select>
    </mat-form-field>
  </div>
  <div class="tb-form-row space-between column-xs">
    <div translate>widgets.time-series-chart.series.point.point-size</div>
    <mat-form-field class="medium-width number" appearance="outline" subscriptSizing="dynamic">
      <input matInput type="number" formControlName="pointSize" min="0" step="1" placeholder="{{ 'widget-config.set' | translate }}"/>
    </mat-form-field>
  </div>
</ng-template>
