<div fxLayout="column" fxFlex="100" fxLayoutAlign="start start" class="card-content-gap">
  <div fxLayout="column" fxLayout.gt-xs="row" fxLayoutAlign.gt-xs="start center" fxLayoutAlign="start stretch" fxFlex="100" class="page-sub-title-container w-100">
    <div fxFlex="70">
      <fa-icon [icon]="faHistory" class="page-title-img mr-1"></fa-icon>
      <span class="page-title">{{swapCaption}} History</span>
    </div>
    <mat-form-field fxFlex="30">
      <input matInput (keyup)="applyFilter()" [(ngModel)]="selFilter" placeholder="Filter">
    </mat-form-field>
  </div>
  <div fxLayout="row" fxLayoutAlign="start center" class="w-100">
    <div [perfectScrollbar] class="table-container" fxFlex="100">
      <mat-progress-bar *ngIf="flgLoading[0]===true" mode="indeterminate"></mat-progress-bar>
      <table mat-table #table [dataSource]="listSwaps" matSort [ngClass]="{'overflow-auto error-border': flgLoading[0]==='error','overflow-auto': true}">
        <ng-container matColumnDef="status">
          <th mat-header-cell *matHeaderCellDef mat-sort-header> Status </th>
          <td mat-cell *matCellDef="let swap">{{swapStateEnum[swap.status]}}</td>
        </ng-container>
        <ng-container matColumnDef="id">
          <th mat-header-cell *matHeaderCellDef mat-sort-header> Swap ID </th>
          <td mat-cell *matCellDef="let swap">{{swap.id}}</td>
        </ng-container>
        <ng-container matColumnDef="claimAddress">
          <th mat-header-cell *matHeaderCellDef mat-sort-header> Claim Address </th>
          <td mat-cell *matCellDef="let swap">{{swap.claimAddress}}</td>
        </ng-container>
        <ng-container matColumnDef="onchainAmount">
          <th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Onchain Amount (Sats) </th>
          <td mat-cell *matCellDef="let swap">
            <span fxLayoutAlign="end center">{{swap.onchainAmount | number}}</span>
          </td>
        </ng-container>
        <ng-container matColumnDef="lockupAddress">
          <th mat-header-cell *matHeaderCellDef mat-sort-header> Lockup Address </th>
          <td mat-cell *matCellDef="let swap">{{swap.lockupAddress}}</td>
        </ng-container>
        <ng-container matColumnDef="expectedAmount">
          <th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Expected Amount (Sats) </th>
          <td mat-cell *matCellDef="let swap">
            <span fxLayoutAlign="end center">{{swap.expectedAmount | number}}</span>
          </td>
        </ng-container>
        <ng-container matColumnDef="timeoutBlockHeight">
          <th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Timeout Block Height </th>
          <td mat-cell *matCellDef="let swap">
            <span fxLayoutAlign="end center">{{swap.timeoutBlockHeight | number}}</span>
          </td>
        </ng-container>
        <ng-container matColumnDef="amt">
          <th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Amount (Sats) </th>
          <td mat-cell *matCellDef="let swap">
            <span fxLayoutAlign="end center">{{swap.amt | number}}</span>
          </td>
        </ng-container>
        <ng-container matColumnDef="actions">
          <th mat-header-cell *matHeaderCellDef class="px-3">
            <div class="bordered-box table-actions-select">
              <mat-select placeholder="Actions" tabindex="1" class="mr-0">
                <mat-select-trigger></mat-select-trigger>
                <mat-option (click)="onDownloadCSV()">Download CSV</mat-option>
              </mat-select>
            </div>
          </th>
          <td mat-cell *matCellDef="let swap" class="pl-3" fxLayoutAlign="end center">
            <button mat-stroked-button color="primary" type="button" tabindex="4"
              (click)="onSwapClick(swap, $event)">View Info</button>
          </td>
        </ng-container>
        <ng-container matColumnDef="no_swap">
          <td mat-footer-cell *matFooterCellDef colspan="4">
            <p *ngIf="!listSwaps?.data || listSwaps?.data?.length<1">{{emptyTableMessage}}</p>
          </td>
        </ng-container>
        <tr mat-footer-row *matFooterRowDef="['no_swap']" [ngClass]="{'display-none': listSwaps?.data && listSwaps?.data?.length>0}"></tr>
        <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: flgSticky;"></tr>
        <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
      </table>
      <mat-paginator [pageSize]="pageSize" [pageSizeOptions]="pageSizeOptions" [showFirstLastButtons]="screenSize === screenSizeEnum.XS ? false : true" class="mb-1"></mat-paginator>
    </div>
  </div>
</div>
