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

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

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

<ng-template #tagContent>
  <cvc-icon-badges
    [flagged]="variantgroup.flagged"
    [entityColor]="iconColor">
    <i
      nz-icon
      nzType="civic-variantgroup"
      nzTheme="twotone"
      [nzTwotoneColor]="'VariantGroup' | entityColor">
    </i>
  </cvc-icon-badges>
  {{ variantgroup.name }}
</ng-template>
