<!--

    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="flex flex-row items-center justify-between" style="margin: 0 10px 4px; min-height: 36px">
  <div style="font-weight: 500; letter-spacing: .25px" translate>notification.notification</div>
  @if ((notifications$ | async)?.length) {
    <button mat-button color="primary"
            (click)="markAsAllRead($event)">
      {{ 'notification.mark-all-as-read' | translate }}
    </button>
  }
</section>
<mat-divider></mat-divider>
@if (notifications$ | async) {
  @if ((notifications$ | async).length) {
    <div style="overflow: auto">
      <section style="min-height: 100px; overflow: auto; padding: 6px 0;">
        @for (notification of (notifications$ | async); track notification.id.id; let last = $last) {
          <div>
            <tb-notification [notification]="notification"
                             [onClose]="onClose"
                             (markAsRead)="markAsRead($event)">
            </tb-notification>
            @if (!last) {
              <mat-divider style="margin: 4px"></mat-divider>
            }
          </div>
        }
      </section>
    </div>
  } @else {
    <div class="tb-no-notification-svg-color" style="margin: 20px 24%">
      <svg height="100%" preserveAspectRatio="xMidYMid meet" viewBox="0 0 149 156" width="100%">
        <use [attr.xlink:href]="'assets/notification-bell.svg#CHECK_ICON'"></use>
      </svg>
    </div>
    <span style="text-align: center; margin-bottom: 12px" translate>notification.no-notifications-yet</span>
  }
  @if ((notifications$ | async).length) {
    <mat-divider></mat-divider>
  }
  @if ((notifications$ | async).length) {
    <section class="flex items-center justify-center">
      <button class="flex-1" mat-button color="primary" (click)="viewAll($event)">
        {{ 'notification.view-all' | translate }}
      </button>
    </section>
  }
} @else {
  <div class="tb-no-data-available" style="margin: 20px; gap: 16px;">
    <mat-spinner color="accent" diameter="65" strokeWidth="4"></mat-spinner>
    <div class="tb-no-data-text" translate>notification.loading-notifications</div>
  </div>
}
