<ng-container *ngIf="linked; else unlinked">
  <a [routerLink]="disease.link">
    <ng-template [ngTemplateOutlet]="tag"></ng-template>
  </a>
</ng-container>

<ng-template #tag>
  <nz-tag
    [ngClass]="{ deprecated: disease.deprecated }"
    nz-popover
    [nzPopoverMouseEnterDelay]="0.5"
    [nzPopoverContent]="enablePopover ? diseasePopover : undefined"
    [nzPopoverPlacement]="popoverPlacement">
    <ng-template [ngTemplateOutlet]="tagContent"></ng-template>
  </nz-tag>

  <ng-template #diseasePopover>
    <cvc-disease-popover
      [diseaseId]="disease.id"
      (contentRendered)="updatePopoverPosition()"></cvc-disease-popover>
  </ng-template>
</ng-template>

<ng-template #unlinked>
  <ng-template [ngTemplateOutlet]="tag"></ng-template>
</ng-template>

<ng-template #tagContent>
  <i
    nz-icon
    nzType="civic-disease"
    nzTheme="twotone"
    nzTwotoneColor="#E62F76"></i>
  <ng-container *ngIf="truncateLongName; else fullName">
    {{ disease.name | truncate: 27 }}
  </ng-container>
  <ng-template #fullName>
    {{ disease.name }}
  </ng-template>
</ng-template>
