import { Component, EventEmitter, Input, Output } from "@angular/core";
import { FormControl, FormGroup } from "@angular/forms";
import { isNullOrUndefined } from "@seniorsistemas/angular-components/utils";
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/forms";
import * as i3 from "@seniorsistemas/angular-components/checkbox-list";
import * as i4 from "./components/thumbnail-item-video/thumbnail-item-video.component";
import * as i5 from "./components/thumbnail-item-image/thumbnail-item-image.component";
import * as i6 from "@ngx-translate/core";
export class ThumbnailItemComponent {
    itemData;
    isCheckable = true;
    isChecked = false;
    combineCheckboxEvent = true;
    checked = new EventEmitter();
    opened = new EventEmitter();
    checkboxFormGroup = new FormGroup({});
    ngOnInit() {
        this._validateItemData();
        this._createFormGroup();
    }
    onClick() {
        this.opened.emit(this.itemData);
    }
    checkboxClick(event) {
        if (this.combineCheckboxEvent) {
            return;
        }
        event.stopPropagation();
    }
    _createFormGroup() {
        this.checkboxFormGroup = new FormGroup({
            checkbox: new FormControl({ checked: this.isChecked }),
        });
        this.checkboxFormGroup.get("checkbox")?.valueChanges.subscribe((value) => {
            this.checked.emit({ item: this.itemData, selected: value.checked });
        });
    }
    _validateItemData() {
        if (isNullOrUndefined(this.itemData)) {
            throw new Error("itemData is required");
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ThumbnailItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: ThumbnailItemComponent, selector: "s-thumbnail-item", inputs: { itemData: "itemData", isCheckable: "isCheckable", isChecked: "isChecked", combineCheckboxEvent: "combineCheckboxEvent" }, outputs: { checked: "checked", opened: "opened" }, ngImport: i0, template: "<button\n    *ngIf=\"itemData\"\n    class=\"thumbnail-item\"\n    (click)=\"onClick()\"\n>\n    <div class=\"thumbnail-item-content\">\n        <div class=\"content\">\n            <ng-container *ngIf=\"itemData.type === 'video'\">\n                <s-thumbnail-item-video\n                    [imageUrl]=\"itemData.imageUrl ? itemData.imageUrl : ''\"\n                    [videoUrl]=\"itemData.videoUrl ? itemData.videoUrl : ''\"\n                >\n                </s-thumbnail-item-video>\n            </ng-container>\n            <ng-container *ngIf=\"itemData.type === 'image'\">\n                <s-thumbnail-item-image\n                    [imageUrl]=\"itemData.imageUrl ? itemData.imageUrl : ''\"\n                ></s-thumbnail-item-image>\n            </ng-container>\n            <ng-container *ngIf=\"itemData.type === 'audio'\">\n                <i class=\"icon fas fa-volume-down\"></i>\n                <span class=\"label\">{{ 'platform.angular_components.listen' | translate }}</span>\n            </ng-container>\n            <ng-container *ngIf=\"itemData.type === 'file'\">\n                <i class=\"icon fas fa-file-alt\"></i>\n                <span class=\"label\">{{ 'platform.angular_components.view' | translate }}</span>\n            </ng-container>\n        </div>\n        <form\n            *ngIf=\"isCheckable\"\n            [formGroup]=\"checkboxFormGroup\"\n            class=\"checkbox\"\n        >\n            <s-checkbox-list\n                [data]=\"{ label: '' }\"\n                formControlName=\"checkbox\"\n                (click)=\"checkboxClick($event)\"\n            ></s-checkbox-list>\n        </form>\n    </div>\n    <span class=\"file-name-label\">{{ itemData.fileName }}</span>\n</button>\n", styles: [".thumbnail-item{align-items:center;background:transparent;border:none;cursor:pointer;display:inline-flex;flex-direction:column;justify-content:center;overflow:hidden;width:100px}.thumbnail-item-content{align-items:center;background-image:linear-gradient(to top right,#5288b6,#00c89a);border-radius:8px;display:flex;flex-direction:column;height:100px;justify-content:center;position:relative;-webkit-user-select:none;user-select:none;width:100%;overflow:hidden}.thumbnail-item-content .checkbox{position:absolute;right:8px;top:8px}.thumbnail-item-content .content{align-items:center;color:#fff;display:flex;flex-direction:column;gap:4px;overflow:hidden;width:100%}.thumbnail-item-content .content .icon{font-size:24px}.thumbnail-item-content .content .label{font-size:12px;width:100%;padding:0 8px;overflow:hidden;text-overflow:ellipsis}.thumbnail-item:hover{transform:scale(1.05);transition:all .2s ease-in-out}.thumbnail-item .file-name-label{color:#525966;font-family:Open Sans,sans-serif;font-size:12px;overflow:hidden;text-align:center;text-overflow:ellipsis;text-wrap:nowrap;-webkit-user-select:none;user-select:none;width:100%}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i3.CheckboxListComponent, selector: "s-checkbox-list", inputs: ["data"] }, { kind: "component", type: i4.ThumbnailItemVideoComponent, selector: "s-thumbnail-item-video", inputs: ["imageUrl", "videoUrl"] }, { kind: "component", type: i5.ThumbnailItemImageComponent, selector: "s-thumbnail-item-image", inputs: ["imageUrl"] }, { kind: "pipe", type: i6.TranslatePipe, name: "translate" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ThumbnailItemComponent, decorators: [{
            type: Component,
            args: [{ selector: "s-thumbnail-item", template: "<button\n    *ngIf=\"itemData\"\n    class=\"thumbnail-item\"\n    (click)=\"onClick()\"\n>\n    <div class=\"thumbnail-item-content\">\n        <div class=\"content\">\n            <ng-container *ngIf=\"itemData.type === 'video'\">\n                <s-thumbnail-item-video\n                    [imageUrl]=\"itemData.imageUrl ? itemData.imageUrl : ''\"\n                    [videoUrl]=\"itemData.videoUrl ? itemData.videoUrl : ''\"\n                >\n                </s-thumbnail-item-video>\n            </ng-container>\n            <ng-container *ngIf=\"itemData.type === 'image'\">\n                <s-thumbnail-item-image\n                    [imageUrl]=\"itemData.imageUrl ? itemData.imageUrl : ''\"\n                ></s-thumbnail-item-image>\n            </ng-container>\n            <ng-container *ngIf=\"itemData.type === 'audio'\">\n                <i class=\"icon fas fa-volume-down\"></i>\n                <span class=\"label\">{{ 'platform.angular_components.listen' | translate }}</span>\n            </ng-container>\n            <ng-container *ngIf=\"itemData.type === 'file'\">\n                <i class=\"icon fas fa-file-alt\"></i>\n                <span class=\"label\">{{ 'platform.angular_components.view' | translate }}</span>\n            </ng-container>\n        </div>\n        <form\n            *ngIf=\"isCheckable\"\n            [formGroup]=\"checkboxFormGroup\"\n            class=\"checkbox\"\n        >\n            <s-checkbox-list\n                [data]=\"{ label: '' }\"\n                formControlName=\"checkbox\"\n                (click)=\"checkboxClick($event)\"\n            ></s-checkbox-list>\n        </form>\n    </div>\n    <span class=\"file-name-label\">{{ itemData.fileName }}</span>\n</button>\n", styles: [".thumbnail-item{align-items:center;background:transparent;border:none;cursor:pointer;display:inline-flex;flex-direction:column;justify-content:center;overflow:hidden;width:100px}.thumbnail-item-content{align-items:center;background-image:linear-gradient(to top right,#5288b6,#00c89a);border-radius:8px;display:flex;flex-direction:column;height:100px;justify-content:center;position:relative;-webkit-user-select:none;user-select:none;width:100%;overflow:hidden}.thumbnail-item-content .checkbox{position:absolute;right:8px;top:8px}.thumbnail-item-content .content{align-items:center;color:#fff;display:flex;flex-direction:column;gap:4px;overflow:hidden;width:100%}.thumbnail-item-content .content .icon{font-size:24px}.thumbnail-item-content .content .label{font-size:12px;width:100%;padding:0 8px;overflow:hidden;text-overflow:ellipsis}.thumbnail-item:hover{transform:scale(1.05);transition:all .2s ease-in-out}.thumbnail-item .file-name-label{color:#525966;font-family:Open Sans,sans-serif;font-size:12px;overflow:hidden;text-align:center;text-overflow:ellipsis;text-wrap:nowrap;-webkit-user-select:none;user-select:none;width:100%}\n"] }]
        }], propDecorators: { itemData: [{
                type: Input
            }], isCheckable: [{
                type: Input
            }], isChecked: [{
                type: Input
            }], combineCheckboxEvent: [{
                type: Input
            }], checked: [{
                type: Output
            }], opened: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 