@if ((dataService.reportStatus$ | async) == ReportStatusEnum.Loading) {
  <dirt-report-loading></dirt-report-loading>
} @else {
  @let drawerDetails = dataService.drawerDetails$ | async;
  <div class="tw-mt-4 tw-flex tw-flex-col">
    <div class="tw-flex tw-mb-4 tw-gap-4 tw-items-center">
      <bit-search
        [placeholder]="'searchApps' | i18n"
        class="tw-min-w-96 tw-w-1/2"
        [formControl]="searchControl"
      ></bit-search>

      <bit-chip-select
        [placeholderText]="'filter' | i18n"
        placeholderIcon="bwi-sliders"
        [options]="filterOptions()"
        [ngModel]="selectedFilter()"
        (ngModelChange)="setFilterApplicationsByStatus($event)"
        fullWidth="false"
        class="tw-min-w-48"
      >
      </bit-chip-select>

      <div class="tw-ml-auto tw-gap-4 tw-flex">
        @if (selectedUrls().size > 0) {
          @if (allSelectedAppsAreCritical()) {
            <button
              type="button"
              [buttonType]="'primary'"
              bitButton
              class="tw-ml-auto"
              [loading]="updatingCriticalApps()"
              (click)="unmarkAppsAsCritical()"
              data-testid="unmark-critical-button"
            >
              {{ "markAppCountAsNotCritical" | i18n: selectedUrls().size }}
            </button>
          } @else {
            <button
              type="button"
              [buttonType]="'primary'"
              bitButton
              class="tw-ml-auto"
              [loading]="updatingCriticalApps()"
              (click)="markAppsAsCritical()"
              data-testid="mark-critical-button"
            >
              {{ "markAppCountAsCritical" | i18n: selectedUrls().size }}
            </button>
          }
        }

        <button
          bitButton
          buttonType="secondary"
          type="button"
          [disabled]="!enableRequestPasswordChange()"
          [bitTooltip]="!enableRequestPasswordChange() ? ('allTasksAssigned' | i18n) : null"
          [addTooltipToDescribedby]="!enableRequestPasswordChange()"
          (click)="requestPasswordChange()"
          data-testid="assign-tasks-button"
        >
          <bit-icon class="tw-mr-2" name="bwi-envelope" />
          {{ "assignTasks" | i18n }}
        </button>

        <button
          type="button"
          bitIconButton="bwi-download"
          buttonType="main"
          [label]="'downloadCSV' | i18n"
          [disabled]="!dataSource.filteredData.length"
          (click)="downloadApplicationsCSV()"
        ></button>
      </div>
    </div>

    <app-table-row-scrollable-m11
      [dataSource]="dataSource"
      [selectedUrls]="selectedUrls()"
      [openApplication]="drawerDetails.invokerId || ''"
      [checkboxChange]="onCheckboxChange"
      [showAppAtRiskMembers]="showAppAtRiskMembers"
      class="tw-mb-10"
    ></app-table-row-scrollable-m11>

    @if (emptyTableExplanation()) {
      <div class="tw-flex tw-mt-10 tw-justify-center">
        <span bitTypography="body2">{{ emptyTableExplanation() }}</span>
      </div>
    }
  </div>
}
