<div class="container-xl">

  <div class="title-block">
    <h1>Block <ng-template [ngIf]="blockHeight"><a [routerLink]="['/block/' | relativeUrl, blockHash]">{{ blockHeight }}</a></ng-template></h1>
  </div>

  <div class="clearfix"></div>

  <ng-template [ngIf]="!isLoading && !error">

    <div class="box">
      <div class="row">
        <div class="col-sm">
          <table class="table table-borderless table-striped">
            <tbody>
              <tr>
                <td class="td-width">Hash</td>
                <td><a [routerLink]="['/block/' | relativeUrl, block.hash]" title="{{ block.hash }}">{{ block.hash | shortenString : 13 }}</a> <app-clipboard class="d-none d-sm-inline-block" [text]="block.hash"></app-clipboard></td>
              </tr>
              <tr>
                <td>Timestamp</td>
                <td>
                  {{ block.time | date:'yyyy-MM-dd HH:mm' }}
                  <div class="lg-inline">
                    <i>(<app-time-since [time]="block.time / 1000" [fastRender]="true"></app-time-since> ago)</i>
                  </div>
                </td>
              </tr>
          </table>
        </div>
        <div class="col-sm">
          <table class="table table-borderless table-striped">
            <tbody>
              <tr>
                <td class="td-width">Previous hash</td>
                <td><a [routerLink]="['/block/' | relativeUrl, block.previousBlockHash]" title="{{ block.hash }}">{{ block.previousBlockHash | shortenString : 13 }}</a> <app-clipboard class="d-none d-sm-inline-block" [text]="block.previousBlockHash"></app-clipboard></td>
              </tr>
          </table>
        </div>
      </div>
    </div>

    <div class="clearfix"></div>

    <br>

    <h2>{{ block.txs.length | number }} transactions</h2>

    <ng-template ngFor let-tx [ngForOf]="block.txs">

      <div class="header-bg box" style="padding: 10px; margin-bottom: 10px;">
        <a [routerLink]="['/tx/' | relativeUrl, tx.id]" [state]="{ data: tx }">
          <span style="float: left;" class="d-block d-md-none">{{ tx.id | shortenString : 16 }}</span>
          <span style="float: left;" class="d-none d-md-block">{{ tx.id }}</span>
        </a>
        <div class="float-right">
          {{ tx.time | date:'yyyy-MM-dd HH:mm' }}
        </div>
        <div class="clearfix"></div>
      </div>
  
      <app-bisq-transfers [tx]="tx" [showConfirmations]="true"></app-bisq-transfers>
  
      <br>
    </ng-template>

  </ng-template>

  <ng-template [ngIf]="isLoading && !error">
    <div class="box">
      <div class="row">
        <div class="col-sm">
          <table class="table table-borderless table-striped">
            <tbody>
              <tr>
                <td class="td-width">Hash</td>
                <td><span class="skeleton-loader"></span></td>
              </tr>
              <tr>
                <td>Timestamp</td>
                <td><span class="skeleton-loader"></span></td>
              </tr>
          </table>
        </div>
        <div class="col-sm">
          <table class="table table-borderless table-striped">
            <tbody>
              <tr>
                <td class="td-width">Previous hash</td>
                <td><span class="skeleton-loader"></span></td>
              </tr>
          </table>
        </div>
      </div>
    </div>
  </ng-template>

  <ng-template [ngIf]="error">
    <div class="clearfix"></div>

    <div class="text-center">
      Error loading block
      <br>
      <i>{{ error.status }}: {{ error.statusText }}</i>
    </div>
  </ng-template>

</div>