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

<ng-template #tag>
  <nz-tag
    nz-popover
    [ngClass]="{ deprecated: variant.deprecated }"
    [nzPopoverMouseEnterDelay]="0.5"
    [nzPopoverPlacement]="popoverPlacement"
    [nzPopoverContent]="enablePopover ? popoverContent : undefined">
    <ng-template [ngTemplateOutlet]="tagContent"></ng-template>
  </nz-tag>
  <ng-template #popoverContent>
    <cvc-variant-popover
      [variantId]="variant.id"
      (contentRendered)="updatePopoverPosition()"></cvc-variant-popover>
  </ng-template>
</ng-template>

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

<ng-template #tagContent>
  <cvc-icon-badges
    [flagged]="variant.flagged"
    [entityColor]="iconColor">
    <i
      nz-icon
      nzType="civic-variant"
      nzTheme="twotone"
      [nzTwotoneColor]="iconColor"></i>
  </cvc-icon-badges>
  <!-- variant name length mean: 12; mode: 5 (825); max: 68 -->
  <ng-container *ngIf="truncateLongName; else fullName">
    {{ variant.name | truncate: 20 }}
  </ng-container>
  <ng-template #fullName>
    {{ variant.name }}
  </ng-template>
</ng-template>
