<aca-page-layout>
  <div class="aca-page-layout-header">
    <aca-search-ai-input-container
      *ngIf="searchAiInputState.active; else header"
      [agentId]="searchAiInputState.selectedAgentId" />
    <ng-template #header>
      <div class="aca-header-container">
        <h1 class="aca-page-title">
      {{ (selectedRowItemsCount < 1 ? 'APP.BROWSE.RECENT.TITLE' : 'APP.HEADER.SELECTED') | translate: { count: selectedRowItemsCount } }}
    </h1>
        <aca-toolbar [items]="actions" />
      </div>
    </ng-template>
  </div>

  <div class="aca-page-layout-content">
    <div class="aca-main-content">
      <adf-document-list
        #documentList
        acaDocumentList
        acaContextActions
        [currentFolderId]="'-recent-'"
        [selectionMode]="'multiple'"
        [multiselect]="true"
        [navigate]="false"
        [sorting]="['modifiedAt', 'desc']"
        [preselectNodes]="selectedNodesState?.nodes"
        [sortingMode]="'client'"
        [imageResolver]="imageResolver"
        [isResizingEnabled]="true"
        [displayCheckboxesOnHover]="true"
        (selectedItemsCountChanged)="onSelectedItemsCountChanged($event)"
        [blurOnResize]="false"
        (node-dblclick)="handleNodeClick($event)"
        (name-click)="handleNodeClick($event)"
      >
        <adf-custom-empty-content-template>
          <adf-empty-content icon="access_time" [title]="'APP.BROWSE.RECENT.EMPTY_STATE.TITLE'" subtitle="APP.BROWSE.RECENT.EMPTY_STATE.TEXT" />
        </adf-custom-empty-content-template>

        <data-columns>
          <ng-container *ngFor="let column of columns; trackBy: trackByColumnId">
            <ng-container *ngIf="column.template && !(column.desktopOnly && isSmallScreen)">
              <data-column
                [id]="column.id"
                [key]="column.key"
                [title]="column.title"
                [type]="column.type"
                [format]="column.format"
                [class]="column.class"
                [sortable]="column.sortable"
                [draggable]="column.draggable"
                [resizable]="column.resizable"
                [isHidden]="column.isHidden"
                [sortingKey]="column.sortingKey || column.key"
              >
                <ng-template let-context>
                  <adf-dynamic-column [id]="column.template" [context]="context" />
                </ng-template>
              </data-column>
            </ng-container>

            <ng-container *ngIf="!column.template && !(column.desktopOnly && isSmallScreen)">
              <data-column
                [id]="column.id"
                [key]="column.key"
                [title]="column.title"
                [type]="column.type"
                [format]="column.format"
                [class]="column.class"
                [sortable]="column.sortable"
                [isHidden]="column.isHidden"
                [draggable]="column.draggable"
                [resizable]="column.resizable"
                [sortingKey]="column.sortingKey || column.key"
              />
            </ng-container>
          </ng-container>
        </data-columns>
      </adf-document-list>

      <adf-pagination acaPagination [target]="documentList" />
    </div>

    <div class="aca-sidebar" *ngIf="infoDrawerOpened$ | async">
      <aca-info-drawer [node]="selection.last" />
    </div>
  </div>
</aca-page-layout>
