<!--

    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 class="tb-round-switch flex flex-col" [style.pointer-events]="ctx.isEdit ? 'none' : 'all'">
  <div #switchTitleContainer class="title-container flex max-h-20% flex-full flex-row items-center justify-center" [class.!hidden]="!showTitle">
    <span #switchTitle class="switch-title">{{title}}</span>
  </div>
  <div #switchContainer class="flex flex-full flex-col items-center justify-center"
       [class]="{
          'max-h-80%': showTitle,
          'max-h-100%': !showTitle
       }"
       [style.padding-top]="showTitle ? '5px': '10px'" id="switch-container">
    <div #switch class="switch">
      <input #onoff type="checkbox" id="{{checkboxId}}" name="onoff" />
      <div class="back">
        <label class="but" for="{{checkboxId}}">
          <span class="on">I</span>
          <span class="off">0</span>
        </label>
      </div>
    </div>
  </div>
  <div #switchErrorContainer class="error-container flex flex-row items-center justify-center" [style.background]="error?.length ? 'rgba(255,255,255,0.25)' : 'none'">
    <span #switchError class="switch-error">{{ error }}</span>
  </div>
  <div #textMeasure id="text-measure"></div>
</div>
