import { Component, Input, Output, EventEmitter } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@ngx-translate/core";
export class TagsComponent {
    constructor() {
        /**The ID of this set of tags */
        this.id = '';
        /**
         * Determines whether the tags will wrap or not
         *
         * @type {boolean}
         * @memberof TagsComponent
         */
        this.wrap = true;
        /**
         * Displays the tags in condensed mode
         */
        this.isCondensed = false;
        /**
         * Emits the tag item when the tag's close button is clicked
         */
        this.tagClosed = new EventEmitter();
        /**
         * Tags to be displayed
         *
         * @type {Tag[]}
         * @memberof TagsComponent
         */
        this.tagsArray = [];
    }
    /**
     * Angular onChanges lifecycle hook
     * @see {@link https://angular.io/guide/lifecycle-hooks | Life-cycle hooks}
     *
     * @param {SimpleChanges} changes
     * @memberof TagsComponent
     */
    ngOnChanges(changes) {
        if (changes.tags) {
            if (this.tags) {
                // If only given a single item, put it in an array so it works in the template
                if (Array.isArray(this.tags)) {
                    this.tagsArray = this.tags;
                }
                else {
                    this.tagsArray = [this.tags];
                }
            }
            else {
                // reset array if tags becomes undefined
                this.tagsArray = [];
            }
        }
    }
    closeTag(tag) {
        this.tagsArray = this.tagsArray.filter(t => t !== tag);
        this.tagClosed.emit(tag);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TagsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TagsComponent, selector: "ec-tags", inputs: { id: "id", tags: "tags", wrap: "wrap", isCondensed: "isCondensed" }, outputs: { tagClosed: "tagClosed" }, usesOnChanges: true, ngImport: i0, template: "<ul class=\"tags\"\r\n    [class.is-wrapped]=\"wrap\">\r\n   <li *ngFor=\"let tag of tagsArray; index as i\"\r\n       id=\"{{id}}_tag_{{i}}\"\r\n       class=\"tag is-{{tag.type}} {{tag.classList}} mr-1\"\r\n       [ngClass]=\"{'text-caption-1': !isCondensed, 'text-caption-2': isCondensed, 'is-condensed': isCondensed, 'pr-0': tag.isDismissable, 'is-link': tag.url}\"\r\n       title=\"{{tag.tooltip | translate}}\">\r\n      <i *ngIf=\"tag.icon\"\r\n         class=\"ec-icon {{tag.icon}} ec-icon-sm\"></i>\r\n      <span *ngIf=\"!tag.url\">{{tag.label | translate}}</span>\r\n\r\n      <a *ngIf=\"tag.url\"\r\n         id=\"{{id}}_tag_{{i}}_link\"\r\n         class=\"font-weight-bold\"\r\n         href=\"{{tag.url}}\"\r\n         target=\"{{tag.target}}\">{{tag.label | translate}}</a>\r\n\r\n      <button id=\"{{id}}_tag_{{i}}_dismissButton\"\r\n              *ngIf=\"tag.isDismissable\"\r\n              (click)=\"closeTag(tag)\">\r\n         <i class=\"ec-icon ec-icon-sm icon-cancel\"></i>\r\n      </button>\r\n   </li>\r\n</ul>", styles: ["@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}:host{display:block}.tags{padding:0;margin:0;list-style:none;display:flex}.tags.is-wrapped{flex-wrap:wrap;margin-top:.25rem}.tags.is-wrapped>.tag{margin-bottom:.25rem}.tag{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background-color:var(--ec-color-gray-1);border:2px solid var(--ec-color-gray-4);display:inline-flex;align-items:center;border-radius:calc(var(--ec-border-radius, .25rem) * 3);height:1.5rem;line-height:1.25rem;padding:0 .4375rem;vertical-align:top}.tag>.ec-icon:first-child{margin-right:.1875rem}.tag .ec-icon{display:flex;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;width:auto;height:auto;min-width:1em;justify-content:center}.tag.is-inverted{background-color:var(--ec-background-color);border-color:var(--ec-background-color)}.tag.is-info{background-color:var(--ec-color-cobalt-1);border-color:var(--ec-color-info)}.tag.is-info>.ec-icon:first-child{color:var(--ec-color-info)}.tag.is-success{background-color:var(--ec-color-green-1);border-color:var(--ec-color-success)}.tag.is-success>.ec-icon:first-child{color:var(--ec-color-success)}.tag.is-warning{background-color:var(--ec-color-yellow-1);border-color:var(--ec-color-caution)}.tag.is-warning>.ec-icon:first-child{color:var(--ec-color-caution)}.tag.is-danger{background-color:var(--ec-color-red-1);border-color:var(--ec-color-danger)}.tag.is-danger>.ec-icon:first-child{color:var(--ec-color-danger)}.tag.is-accent{background-color:var(--ec-color-purple-1);border-color:var(--ec-color-accent)}.tag.is-accent>.ec-icon:first-child{color:var(--ec-color-accent)}.tag.is-chargeback{background-color:var(--ec-color-orange-1);border-color:var(--ec-color-orange-7)}.tag.is-chargeback>.ec-icon:first-child{color:var(--ec-color-orange-7)}.tag.is-accrual{background-color:var(--ec-color-aqua-1);border-color:var(--ec-color-aqua-5)}.tag.is-accrual>.ec-icon:first-child{color:var(--ec-color-aqua-5)}.tag.is-system{background-color:var(--ec-color-gray-1);border-color:var(--ec-color-gray-4)}.tag.is-system>.ec-icon:first-child{color:var(--ec-color-gray-4)}button{background-color:transparent;border:0;display:flex;align-items:center;padding:0 .25rem;height:100%;cursor:pointer;position:relative}button:hover,button:focus{outline:none}button:hover:before,button:focus:before{display:block;content:\"\";position:absolute;inset:.0625rem .125rem;background-color:#1a1a231a;border-radius:.125rem}.is-condensed{border-radius:var(--ec-border-radius);border-width:1px;padding:0 .25rem;height:1.125rem;line-height:1.125rem;min-width:1.125rem;justify-content:center}.is-condensed>.ec-icon:first-child{margin-right:.125rem}.is-link a:after{opacity:1;margin-left:.1875rem}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TagsComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ec-tags', template: "<ul class=\"tags\"\r\n    [class.is-wrapped]=\"wrap\">\r\n   <li *ngFor=\"let tag of tagsArray; index as i\"\r\n       id=\"{{id}}_tag_{{i}}\"\r\n       class=\"tag is-{{tag.type}} {{tag.classList}} mr-1\"\r\n       [ngClass]=\"{'text-caption-1': !isCondensed, 'text-caption-2': isCondensed, 'is-condensed': isCondensed, 'pr-0': tag.isDismissable, 'is-link': tag.url}\"\r\n       title=\"{{tag.tooltip | translate}}\">\r\n      <i *ngIf=\"tag.icon\"\r\n         class=\"ec-icon {{tag.icon}} ec-icon-sm\"></i>\r\n      <span *ngIf=\"!tag.url\">{{tag.label | translate}}</span>\r\n\r\n      <a *ngIf=\"tag.url\"\r\n         id=\"{{id}}_tag_{{i}}_link\"\r\n         class=\"font-weight-bold\"\r\n         href=\"{{tag.url}}\"\r\n         target=\"{{tag.target}}\">{{tag.label | translate}}</a>\r\n\r\n      <button id=\"{{id}}_tag_{{i}}_dismissButton\"\r\n              *ngIf=\"tag.isDismissable\"\r\n              (click)=\"closeTag(tag)\">\r\n         <i class=\"ec-icon ec-icon-sm icon-cancel\"></i>\r\n      </button>\r\n   </li>\r\n</ul>", styles: ["@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}:host{display:block}.tags{padding:0;margin:0;list-style:none;display:flex}.tags.is-wrapped{flex-wrap:wrap;margin-top:.25rem}.tags.is-wrapped>.tag{margin-bottom:.25rem}.tag{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background-color:var(--ec-color-gray-1);border:2px solid var(--ec-color-gray-4);display:inline-flex;align-items:center;border-radius:calc(var(--ec-border-radius, .25rem) * 3);height:1.5rem;line-height:1.25rem;padding:0 .4375rem;vertical-align:top}.tag>.ec-icon:first-child{margin-right:.1875rem}.tag .ec-icon{display:flex;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;width:auto;height:auto;min-width:1em;justify-content:center}.tag.is-inverted{background-color:var(--ec-background-color);border-color:var(--ec-background-color)}.tag.is-info{background-color:var(--ec-color-cobalt-1);border-color:var(--ec-color-info)}.tag.is-info>.ec-icon:first-child{color:var(--ec-color-info)}.tag.is-success{background-color:var(--ec-color-green-1);border-color:var(--ec-color-success)}.tag.is-success>.ec-icon:first-child{color:var(--ec-color-success)}.tag.is-warning{background-color:var(--ec-color-yellow-1);border-color:var(--ec-color-caution)}.tag.is-warning>.ec-icon:first-child{color:var(--ec-color-caution)}.tag.is-danger{background-color:var(--ec-color-red-1);border-color:var(--ec-color-danger)}.tag.is-danger>.ec-icon:first-child{color:var(--ec-color-danger)}.tag.is-accent{background-color:var(--ec-color-purple-1);border-color:var(--ec-color-accent)}.tag.is-accent>.ec-icon:first-child{color:var(--ec-color-accent)}.tag.is-chargeback{background-color:var(--ec-color-orange-1);border-color:var(--ec-color-orange-7)}.tag.is-chargeback>.ec-icon:first-child{color:var(--ec-color-orange-7)}.tag.is-accrual{background-color:var(--ec-color-aqua-1);border-color:var(--ec-color-aqua-5)}.tag.is-accrual>.ec-icon:first-child{color:var(--ec-color-aqua-5)}.tag.is-system{background-color:var(--ec-color-gray-1);border-color:var(--ec-color-gray-4)}.tag.is-system>.ec-icon:first-child{color:var(--ec-color-gray-4)}button{background-color:transparent;border:0;display:flex;align-items:center;padding:0 .25rem;height:100%;cursor:pointer;position:relative}button:hover,button:focus{outline:none}button:hover:before,button:focus:before{display:block;content:\"\";position:absolute;inset:.0625rem .125rem;background-color:#1a1a231a;border-radius:.125rem}.is-condensed{border-radius:var(--ec-border-radius);border-width:1px;padding:0 .25rem;height:1.125rem;line-height:1.125rem;min-width:1.125rem;justify-content:center}.is-condensed>.ec-icon:first-child{margin-right:.125rem}.is-link a:after{opacity:1;margin-left:.1875rem}\n"] }]
        }], ctorParameters: () => [], propDecorators: { id: [{
                type: Input
            }], tags: [{
                type: Input
            }], wrap: [{
                type: Input
            }], isCondensed: [{
                type: Input
            }], tagClosed: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 