<!--

    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.

-->
@if (layoutCtx.widgets.isLoading()) {
  <div class="tb-progress-cover flex flex-col items-center justify-center"
       >
    <mat-spinner color="warn" mode="indeterminate" diameter="100">
    </mat-spinner>
  </div>
}
<div class="mat-content"
     style="position: relative; width: 100%; height: 100%;" [tb-hotkeys]="hotKeys"
     [cheatSheet]="dashboardCheatSheet"
     [style.background-image]="backgroundImage$ | async"
     [style]="dashboardStyle">
  @if (layoutCtx.widgets.isEmpty()) {
    <section
      style="z-index: 1; pointer-events: none;"
      class="mat-headline-5 tb-absolute-fill flex items-center justify-center">
      @if (!isEdit) {
        <span style="text-align: center;">
          {{'dashboard.no-widgets' | translate}}
        </span>
      }
      @if (isEdit && !widgetEditMode) {
        <button mat-button class="tb-add-new-widget"
                (click)="addWidget($event)">
          <mat-icon class="tb-mat-96">add</mat-icon>
          <span>{{ 'dashboard.add-widget' | translate }}</span>
        </button>
      }
    </section>
  }
  <tb-dashboard #dashboard [dashboardStyle]="dashboardStyle"
                [backgroundImage]="backgroundImage$ | async"
                [widgets]="layoutCtx.widgets"
                [widgetLayouts]="layoutCtx.widgetLayouts"
                [columns]="columns"
                [displayGrid]="displayGrid"
                [outerMargin]="outerMargin"
                [margin]="margin"
                [aliasController]="dashboardCtx.aliasController"
                [stateController]="dashboardCtx.stateController"
                [dashboardTimewindow]="dashboardCtx.dashboardTimewindow"
                [isEdit]="isEdit"
                [isEditingWidget]="isEditingWidget"
                [autofillHeight]="autoFillHeight"
                [mobileAutofillHeight]="mobileAutoFillHeight"
                [mobileRowHeight]="mobielRowHeigth"
                [isMobile]="isMobileValue"
                [isMobileDisabled]="isMobileDisabled"
                [disableWidgetInteraction]="isEdit"
                [isEditActionEnabled]="isEdit && !isEditingWidget"
                [isExportActionEnabled]="isEdit && !widgetEditMode && !isEditingWidget"
                [isRemoveActionEnabled]="isEdit && !widgetEditMode && !isEditingWidget"
                [callbacks]="this"
                [ignoreLoading]="layoutCtx.ignoreLoading"
                [parentDashboard]="parentDashboard"
                [popoverComponent]="popoverComponent">
  </tb-dashboard>
</div>
