import { __decorate } from "tslib";
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { CheckDisabled } from '@seniorsistemas/angular-components/shared';
import * as i0 from "@angular/core";
import * as i1 from "@seniorsistemas/angular-components/tooltip";
import * as i2 from "@angular/common";
export class ChipItemComponent {
    dataRender;
    objectField;
    disabled = false;
    templateRef;
    itemIndex = -1;
    showTooltip = true;
    maxLengthRenderWithoutTooltip = 20;
    clickRemove = new EventEmitter();
    chipClicked = new EventEmitter();
    clickedRemove($event) {
        this.clickRemove.emit({ itemIndex: this.itemIndex, event: $event });
    }
    onChipClicked($event) {
        this.chipClicked.emit({ event: $event, data: this.dataRender });
    }
    get _text() {
        const _text = this._rawText;
        return _text.substring(0, _text.length > this.maxLengthRenderWithoutTooltip ? this.maxLengthRenderWithoutTooltip : _text.length) + (_text.length > this.maxLengthRenderWithoutTooltip ? '...' : '');
    }
    get _rawText() {
        return this.objectField ? this.dataRender[this.objectField] || '' : this.dataRender || '';
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ChipItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ChipItemComponent, selector: "s-chip-item", inputs: { dataRender: "dataRender", objectField: "objectField", disabled: "disabled", templateRef: "templateRef", itemIndex: "itemIndex", showTooltip: "showTooltip", maxLengthRenderWithoutTooltip: "maxLengthRenderWithoutTooltip" }, outputs: { clickRemove: "clickRemove", chipClicked: "chipClicked" }, ngImport: i0, template: "<ng-template #itemRender>\n    <div\n        class=\"chip-item\"\n        [class.chip-item-disabled]=\"disabled\"\n        (click)=\"onChipClicked($event)\" \n        [sTooltip]=\"_rawText\"\n        [showDelay]=\"0\"\n        [visible]=\"showTooltip ? _rawText.length > maxLengthRenderWithoutTooltip : false\">\n            @if(templateRef) {\n                <ng-container\n                    *ngTemplateOutlet=\"templateRef; context: { $implicit: dataRender, text: _text }\">\n                </ng-container>\n            } @else {\n                {{ _text }}\n            }\n            <i class=\"fas fa-times\" (click)=\"clickedRemove($event)\"></i>\n    </div>\n</ng-template>\n\n\n@if(objectField && !templateRef) {\n    <ng-container *ngTemplateOutlet=\"itemRender;\"></ng-container>\n}\n\n@if(!objectField && !templateRef) {\n    <ng-container *ngTemplateOutlet=\"itemRender;\"></ng-container>\n}\n\n@if(templateRef) {\n    <ng-container *ngTemplateOutlet=\"itemRender\"></ng-container>\n}\n", styles: [".chip-item{border-radius:4px;border:1px solid #888b99;background-color:#eeebf2;word-break:break-word;font-size:12px;font-weight:400;text-align:center;display:flex;align-items:center;gap:8px;padding:0 6px}.chip-item i{cursor:pointer}.chip-item:hover:not(.chip-item-disabled){background:#c1c1cc}.chip-item-disabled{opacity:.5}.chip-item-disabled i{cursor:default}\n"], dependencies: [{ kind: "directive", type: i1.TooltipDirective, selector: "[sTooltip]", inputs: ["sTooltip", "tooltipPosition", "showDelay", "displayTime", "tooltipEvent", "escape", "visible", "mobileBehavior", "focusedInputRef", "checkTruncatedText"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
}
__decorate([
    CheckDisabled()
], ChipItemComponent.prototype, "clickedRemove", null);
__decorate([
    CheckDisabled()
], ChipItemComponent.prototype, "onChipClicked", null);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ChipItemComponent, decorators: [{
            type: Component,
            args: [{ selector: 's-chip-item', template: "<ng-template #itemRender>\n    <div\n        class=\"chip-item\"\n        [class.chip-item-disabled]=\"disabled\"\n        (click)=\"onChipClicked($event)\" \n        [sTooltip]=\"_rawText\"\n        [showDelay]=\"0\"\n        [visible]=\"showTooltip ? _rawText.length > maxLengthRenderWithoutTooltip : false\">\n            @if(templateRef) {\n                <ng-container\n                    *ngTemplateOutlet=\"templateRef; context: { $implicit: dataRender, text: _text }\">\n                </ng-container>\n            } @else {\n                {{ _text }}\n            }\n            <i class=\"fas fa-times\" (click)=\"clickedRemove($event)\"></i>\n    </div>\n</ng-template>\n\n\n@if(objectField && !templateRef) {\n    <ng-container *ngTemplateOutlet=\"itemRender;\"></ng-container>\n}\n\n@if(!objectField && !templateRef) {\n    <ng-container *ngTemplateOutlet=\"itemRender;\"></ng-container>\n}\n\n@if(templateRef) {\n    <ng-container *ngTemplateOutlet=\"itemRender\"></ng-container>\n}\n", styles: [".chip-item{border-radius:4px;border:1px solid #888b99;background-color:#eeebf2;word-break:break-word;font-size:12px;font-weight:400;text-align:center;display:flex;align-items:center;gap:8px;padding:0 6px}.chip-item i{cursor:pointer}.chip-item:hover:not(.chip-item-disabled){background:#c1c1cc}.chip-item-disabled{opacity:.5}.chip-item-disabled i{cursor:default}\n"] }]
        }], propDecorators: { dataRender: [{
                type: Input,
                args: [{ required: true }]
            }], objectField: [{
                type: Input,
                args: [{ required: true }]
            }], disabled: [{
                type: Input,
                args: [{ required: true }]
            }], templateRef: [{
                type: Input
            }], itemIndex: [{
                type: Input,
                args: [{ required: true }]
            }], showTooltip: [{
                type: Input,
                args: [{ required: true }]
            }], maxLengthRenderWithoutTooltip: [{
                type: Input,
                args: [{ required: true }]
            }], clickRemove: [{
                type: Output
            }], chipClicked: [{
                type: Output
            }], clickedRemove: [], onChipClicked: [] } });
//# sourceMappingURL=data:application/json;base64, 