<!--

    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 #toggleGroupContainer class="tb-toggle-container">
  <mat-button-toggle-group #widgetButton
                           class="tb-toggle-header"
                           [ngModel]="value"
                           (change)="clicked.emit($event)"
                           [style.border-radius]="computedBorderRadius"
                           [style.border-color]="disabled ? 'rgba(0,0,0,0.38)': computedBorderColor"
                           [style.border-width]="computedBorderWidth"
                           [class.tb-pointer-events]="disableEvents"
                           [class.tb-disabled-state]="disabled"
                           [class.tb-disabled]="disabled">
    <mat-button-toggle [value]="true" [disabled]="disabled" [class.tb-hover-state]="hovered">
      @if (appearance.leftAppearance.showIcon || appearance.leftAppearance.showLabel) {
        <div #leftButtonContent class="tb-widget-button-content">
          @if (appearance.leftAppearance.showIcon) {
            <tb-icon matButtonIcon [style]="leftIconStyle">{{ appearance.leftAppearance.icon }}</tb-icon>
          }
          @if (appearance.leftAppearance.showLabel) {
            <span [style]="leftLabelStyle" class="tb-widget-button-label">{{ leftLabel$ | async }}</span>
          }
        </div>
      }
    </mat-button-toggle>
    <mat-button-toggle [value]="false" [disabled]="disabled" [class.tb-hover-state]="hovered">
      @if (appearance.rightAppearance.showIcon || appearance.rightAppearance.showLabel) {
        <div #rightButtonContent class="tb-widget-button-content">
          @if (appearance.rightAppearance.showIcon) {
            <tb-icon matButtonIcon [style]="rightIconStyle">{{ appearance.rightAppearance.icon }}</tb-icon>
          }
          @if (appearance.rightAppearance.showLabel) {
            <span [style]="rightLabelStyle" class="tb-widget-button-label">{{ rightLabel$ | async }}</span>
          }
        </div>
      }
    </mat-button-toggle>
  </mat-button-toggle-group>
</div>
