<!--

    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.

-->
<section class="tb-widget-settings flex flex-col" [formGroup]="flotPieWidgetSettingsForm">
  <fieldset class="fields-group">
    <legend class="group-title" translate>widgets.chart.common-pie-settings</legend>
    <section class="flex flex-col gt-xs:flex-row gt-xs:gap-2">
      <mat-form-field class="mat-block flex-1">
        <mat-label translate>widgets.chart.radius</mat-label>
        <input matInput type="number" step="0.1" min="0" max="1" formControlName="radius">
        @if (flotPieWidgetSettingsForm.get('radius').hasError('min') || flotPieWidgetSettingsForm.get('radius').hasError('max')) {
          <mat-error>
            {{ 'widgets.chart.common-pie-settings-range-error' | translate }}
          </mat-error>
        }
      </mat-form-field>
      <mat-form-field class="mat-block flex-1">
        <mat-label translate>widgets.chart.inner-radius</mat-label>
        <input matInput type="number" step="0.1" min="0" max="1" formControlName="innerRadius">
        @if (flotPieWidgetSettingsForm.get('innerRadius').hasError('min') || flotPieWidgetSettingsForm.get('innerRadius').hasError('max')) {
          <mat-error>
            {{ 'widgets.chart.common-pie-settings-range-error' | translate }}
          </mat-error>
        }
      </mat-form-field>
      <mat-form-field class="mat-block flex-1">
        <mat-label translate>widgets.chart.tilt</mat-label>
        <input matInput type="number" step="0.1" min="0" max="1" formControlName="tilt">
        @if (flotPieWidgetSettingsForm.get('tilt').hasError('min') || flotPieWidgetSettingsForm.get('tilt').hasError('max')) {
          <mat-error>
            {{ 'widgets.chart.common-pie-settings-range-error' | translate }}
          </mat-error>
        }
      </mat-form-field>
    </section>
    <mat-slide-toggle formControlName="showLabels" class="slide-block">
      {{ 'widgets.chart.show-labels' | translate }}
    </mat-slide-toggle>
    <mat-slide-toggle formControlName="showTooltip" class="slide-block">
      {{ 'widgets.chart.show-tooltip' | translate }}
    </mat-slide-toggle>
  </fieldset>
  <fieldset class="fields-group" formGroupName="stroke">
    <legend class="group-title" translate>widgets.chart.stroke-settings</legend>
    <section class="flex flex-row xs:flex-col gt-xs:gap-2">
      <mat-form-field class="mat-block flex-1">
        <mat-label translate>widgets.chart.width-pixels</mat-label>
        <input matInput type="number" min="0" formControlName="width">
      </mat-form-field>
      <tb-color-input class="flex-1"
                      formControlName="color"
                      icon="format_color_fill"
                      label="{{ 'widgets.chart.color' | translate }}" openOnInput colorClearButton>
      </tb-color-input>
    </section>
  </fieldset>
  <fieldset class="fields-group">
    <legend class="group-title" translate>widgets.chart.animation-settings</legend>
    <mat-slide-toggle formControlName="animatedPie" class="slide-block">
      {{ 'widgets.chart.animated-pie' | translate }}
    </mat-slide-toggle>
  </fieldset>
</section>
