<!--

    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]="barSettingsFormGroup">
  <div class="tb-form-row">
    <mat-slide-toggle class="mat-slide" formControlName="showBorder">
      {{ 'widgets.chart.bar.show-border' | translate }}
    </mat-slide-toggle>
  </div>
  <div class="tb-form-row space-between column-xs">
    <div translate>widgets.chart.bar.border-width</div>
    <mat-form-field class="medium-width number" appearance="outline" subscriptSizing="dynamic">
      <input matInput type="number" formControlName="borderWidth" min="0" step="1" placeholder="{{ 'widget-config.set' | translate }}"/>
    </mat-form-field>
  </div>
  <div class="tb-form-row space-between column-xs">
    <div translate>widgets.chart.bar.border-radius</div>
    <mat-form-field class="medium-width number" appearance="outline" subscriptSizing="dynamic">
      <input matInput type="number" formControlName="borderRadius" min="0" step="1" placeholder="{{ 'widget-config.set' | translate }}"/>
    </mat-form-field>
  </div>
  @if (!series) {
    <div class="tb-form-row space-between column-xs">
      <div translate>widgets.chart.bar.bar-width</div>
      <mat-form-field class="medium-width number" appearance="outline" subscriptSizing="dynamic">
        <input matInput type="number" formControlName="barWidth" min="0" max="100" placeholder="{{ 'widget-config.set' | translate }}"/>
        <div matSuffix>%</div>
      </mat-form-field>
    </div>
  }
  <div class="tb-form-row space-between column-lt-md">
    <mat-slide-toggle class="mat-slide" formControlName="showLabel">
      <div tb-hint-tooltip-icon="{{(series ? 'widgets.chart.bar.series-label-hint' : 'widgets.chart.bar.label-hint') | translate}}">
        {{ 'widgets.chart.bar.label' | translate }}
      </div>
    </mat-slide-toggle>
    <div class="flex lt-md:flex-1 flex-row items-center justify-start gap-2">
      <mat-form-field class="medium-width lt-md:flex-1" appearance="outline" subscriptSizing="dynamic">
        <mat-select formControlName="labelPosition">
          @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="labelFont"
                        clearButton
                        disabledLineHeight
                        forceSizeUnit="px"
                        [previewText]="labelPreviewFn">
      </tb-font-settings>
      <tb-color-input asBoxInput
                      colorClearButton
                      formControlName="labelColor">
      </tb-color-input>
    </div>
  </div>
  <div class="tb-form-row space-between">
    <mat-slide-toggle class="mat-slide" formControlName="enableLabelBackground">
      {{ 'widgets.chart.bar.label-background' | translate }}
    </mat-slide-toggle>
    <tb-color-input asBoxInput
                    colorClearButton
                    formControlName="labelBackground">
    </tb-color-input>
  </div>
  <tb-chart-fill-settings
    formControlName="backgroundSettings"
    titleText="widgets.chart.background"
    fillNoneTitle="widgets.chart.fill-type-solid">
  </tb-chart-fill-settings>
</ng-container>
