<!--
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<mat-chip-list>
  <ng-container *ngFor="let key of keys; let i = index">
    <mat-chip *ngIf="isVisible(i)"
              [disableRipple]="true">
      <ng-container *ngIf="isTooLong(map[key]) && !isHref(map[key])">
        <a class="kd-clickable"
           (click)="openChipDialog(key, map[key])">{{key}}</a>
      </ng-container>

      <!-- beautify ignore:start -->
      <ng-container *ngIf="!isTooLong(map[key]) || isHref(map[key])">
        {{key}}<ng-container *ngIf="map[key]">:&nbsp;</ng-container>
        <ng-container *ngIf="map[key]">
          <ng-container *ngIf="isHref(map[key])">
            <a [href]="map[key]"
               target="_blank">
              <span *ngIf="!isTooLong(map[key])">{{map[key]}}</span>
              <span *ngIf="isTooLong(map[key])">{{getTruncatedURL(map[key])}}</span>
            </a>
          </ng-container>
          <ng-container *ngIf="!isHref(map[key])">{{map[key]}}</ng-container>
        </ng-container>
      </ng-container>
      <!-- beautify ignore:end -->

    </mat-chip>
  </ng-container>
  <div *ngIf="isAnythingHidden()"
       (click)="toggleView()"
       class="kd-chips-show-button">
    <ng-container *ngIf="isShowingAll"
                  i18n>Show less</ng-container>
    <ng-container *ngIf="!isShowingAll"
                  i18n>Show all</ng-container>
  </div>
  <ng-container *ngIf="keys.length === 0">-</ng-container>
</mat-chip-list>
