/**
 * @fileoverview added by tsickle
 * Generated from: components/thumbnail/thumbnail.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/*
    MIT License

    Copyright (c) 2018 Temainfo Software

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
*/
import { Component, EventEmitter, Input, Output, TemplateRef } from '@angular/core';
import { LightboxService } from '../lightbox/services/lightbox.service';
import { ThumbnailService } from './thumbnail.service';
import { DialogService } from '../dialog/dialog.service';
export class TlThumbnail {
    /**
     * @param {?} lightboxService
     * @param {?} thumbnailService
     * @param {?} dialogService
     */
    constructor(lightboxService, thumbnailService, dialogService) {
        this.lightboxService = lightboxService;
        this.thumbnailService = thumbnailService;
        this.dialogService = dialogService;
        this.data = [];
        this.bordered = true;
        this.shape = 'square';
        this.size = { width: '80px', height: '80px' };
        this.showDeleteButton = false;
        this.confirmationDeleteMessage = 'Do you want to delete the Thumbnail?';
        this.showConfirmationOnDelete = false;
        this.clickThumbnail = new EventEmitter();
        this.clickDeleteThumbail = new EventEmitter();
    }
    /**
     * @return {?}
     */
    ngOnInit() { }
    /**
     * @param {?} changes
     * @return {?}
     */
    ngOnChanges(changes) {
        if (changes['data'] && changes['data'].currentValue) {
            if (((/** @type {?} */ (changes['data'].currentValue))).length > 0) {
                this.data = ((/** @type {?} */ (changes['data'].currentValue))).map((/**
                 * @param {?} file
                 * @return {?}
                 */
                (file) => {
                    file.type = !file.type ? this.thumbnailService.getMimeType(file.file) : file.type;
                    return file;
                }));
            }
        }
    }
    /**
     * @return {?}
     */
    get isCircle() {
        return this.shape === 'circle';
    }
    /**
     * @param {?} image
     * @return {?}
     */
    onViewImage(image) {
        this.lightboxService.create(this.data, image);
    }
    /**
     * @param {?} image
     * @return {?}
     */
    onDeleteThumb(image) {
        if (this.showConfirmationOnDelete) {
            return this.dialogService.confirmation(this.confirmationDeleteMessage, ({
                isYes: (/**
                 * @return {?}
                 */
                () => this.clickDeleteThumbail.emit(image)),
            }), {}, this.modalDeleteOptions);
        }
        this.clickDeleteThumbail.emit(image);
    }
}
TlThumbnail.decorators = [
    { type: Component, args: [{
                selector: 'tl-thumbnail',
                template: "\n<div class=\"thumbnail-container\">\n  <ng-container *ngIf=\"data.length > 0; else thumbTemplate\">\n    <ng-container *ngFor=\"let item of data\">\n      <ng-container *ngTemplateOutlet=\"thumbTemplate; context: { $implicit: item }\"></ng-container>\n    </ng-container>\n  </ng-container>\n</div>\n\n<ng-template #thumbTemplate let-item>\n  <div class=\"thumbnail\" (click)=\"clickThumbnail.emit($event)\"\n       [style.width]=\"size.width\"\n       [style.height]=\"size.height\"\n       [class.circle-shape]=\"isCircle\"\n       [class.borderLess]=\"!bordered\">\n    <ng-container *ngIf=\"!item && !image; else imageTemplate\">\n      <ng-container *ngTemplateOutlet=\"emptyTemplate\"></ng-container>\n    </ng-container>\n    <ng-template #imageTemplate>\n      <div *ngIf=\"item.type === 'image/png' || item.type === 'image/jpeg' || item.type === 'image/bmp' || item.type === 'image/jpg' || item.type === 'image' ||\n                   mimeType === 'image/png' ||  mimeType === 'image/jpeg' ||  mimeType === 'image/bmp' ||  mimeType === 'image/jpg' ||  mimeType === 'image'\"\n           class=\"thumbnail-image-wrapper\" [class.circle-shape]=\"isCircle\">\n        <img class=\"thumbnail-image\" [class.circle-shape]=\"isCircle\" alt=\"image\" [src]=\"item.file || image\">\n        <div class=\"thumbnail-controls\" *ngIf=\"!overlayTemplate\">\n          <div class=\"view-button\" [style.width]=\"size.width\" [style.height]=\"size.height\" (click)=\"onViewImage( image )\">\n            <tl-icon [lib]=\"'dx'\">find</tl-icon>\n          </div>\n          <div class=\"trash-button\" (click)=\"onDeleteThumb(item)\">\n            <tl-icon *ngIf=\"showDeleteButton\"  [lib]=\"'dx'\">trash</tl-icon>\n          </div>\n        </div>\n        <div class=\"thumbnail-controls\" *ngIf=\"overlayTemplate\">\n          <ng-container *ngTemplateOutlet=\"overlayTemplate; context: { $implicit: item || image }\"></ng-container>\n        </div>\n      </div>\n\n      <div *ngIf=\"item.type === 'application/pdf' || mimeType === 'application/pdf'\" class=\"thumbnail-image-wrapper\" [class.circle-shape]=\"isCircle\">\n        <tl-icon style=\"margin-right: 5px\" [lib]=\"'fa'\" [style]=\"'fas'\" [color]=\"'#ec7e7e'\" [size]=\"'40px'\">file-pdf</tl-icon>\n        <div class=\"thumbnail-controls\" *ngIf=\"!overlayTemplate\">\n          <div class=\"view-button\" [style.width]=\"size.width\" [style.height]=\"size.height\" (click)=\"onViewImage( image )\">\n            <tl-icon [lib]=\"'dx'\">find</tl-icon>\n          </div>\n          <div class=\"trash-button\" (click)=\"onDeleteThumb(item)\">\n            <tl-icon *ngIf=\"showDeleteButton\"  [lib]=\"'dx'\">trash</tl-icon>\n          </div>\n        </div>\n        <div class=\"thumbnail-controls\" *ngIf=\"overlayTemplate\">\n          <ng-container *ngTemplateOutlet=\"overlayTemplate; context: { $implicit: item || image }\"></ng-container>\n        </div>\n      </div>\n    </ng-template>\n  </div>\n</ng-template>\n\n",
                styles: [".thumbnail-container{display:flex}.thumbnail-container>.thumbnail{align-items:center;background-color:#fafafa;border:1px dashed #d9d9d9;box-sizing:border-box;cursor:pointer;display:flex;flex-flow:column;height:80px;justify-content:center;margin:0 5px;padding:2px;position:relative;transition:border-color .3s ease;width:100px}.thumbnail-container>.thumbnail>.icon{color:#e6e6e6;cursor:pointer;font-size:22px}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper{align-items:center;border-radius:5px;display:flex;height:100%;justify-content:center;overflow:hidden;width:100%}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper.circle-shape:before{border-radius:50%}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper:hover .thumbnail-controls{opacity:1}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper:before{background-color:rgba(0,0,0,.5);content:\" \";height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .3s;width:100%;z-index:1}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper>.thumbnail-image{-o-object-fit:cover;display:block;height:100%;object-fit:cover;position:static;width:100%}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper>.thumbnail-image.circle-shape{border-radius:50%}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper>.thumbnail-controls{align-items:center;color:#fff;cursor:pointer;display:flex;font-size:22px;height:100%;justify-content:center;left:0;opacity:0;position:absolute;top:0;width:100%;z-index:1000}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper>.thumbnail-controls>.view-button{align-content:center;align-items:center;display:flex;justify-content:center;margin-top:10px}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper>.thumbnail-controls>.view-button>tl-icon{margin-bottom:10px}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper>.thumbnail-controls>.trash-button{align-items:center;background-color:#ec7e7e;cursor:pointer;display:flex;height:15px;justify-content:center;position:absolute;right:0;top:0}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper>.thumbnail-controls>.trash-button>tl-icon{font-size:10px}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper>.thumbnail-controls .icon{cursor:pointer}.thumbnail-container>.thumbnail>.thumbnail-image-wrapper>.thumbnail-controls .icon:last-child{padding-left:10px}.thumbnail-container>.thumbnail:hover .thumbnail-image-wrapper:before{opacity:1}.thumbnail-container>.thumbnail.borderLess{border:0}.thumbnail-container>.thumbnail.circle-shape{border-radius:50%}.thumbnail-container>.thumbnail.marginLess{margin-left:0!important}.thumbnail-container>.thumbnail:first-child{margin-left:8px}.thumbnail-container>.thumbnail:hover{border-color:#6c9}"]
            }] }
];
/** @nocollapse */
TlThumbnail.ctorParameters = () => [
    { type: LightboxService },
    { type: ThumbnailService },
    { type: DialogService }
];
TlThumbnail.propDecorators = {
    image: [{ type: Input }],
    mimeType: [{ type: Input }],
    data: [{ type: Input }],
    bordered: [{ type: Input }],
    shape: [{ type: Input }],
    size: [{ type: Input }],
    showDeleteButton: [{ type: Input }],
    confirmationDeleteMessage: [{ type: Input }],
    showConfirmationOnDelete: [{ type: Input }],
    modalDeleteOptions: [{ type: Input }],
    overlayTemplate: [{ type: Input }],
    emptyTemplate: [{ type: Input }],
    clickThumbnail: [{ type: Output }],
    clickDeleteThumbail: [{ type: Output }]
};
if (false) {
    /** @type {?} */
    TlThumbnail.prototype.image;
    /** @type {?} */
    TlThumbnail.prototype.mimeType;
    /** @type {?} */
    TlThumbnail.prototype.data;
    /** @type {?} */
    TlThumbnail.prototype.bordered;
    /** @type {?} */
    TlThumbnail.prototype.shape;
    /** @type {?} */
    TlThumbnail.prototype.size;
    /** @type {?} */
    TlThumbnail.prototype.showDeleteButton;
    /** @type {?} */
    TlThumbnail.prototype.confirmationDeleteMessage;
    /** @type {?} */
    TlThumbnail.prototype.showConfirmationOnDelete;
    /** @type {?} */
    TlThumbnail.prototype.modalDeleteOptions;
    /** @type {?} */
    TlThumbnail.prototype.overlayTemplate;
    /** @type {?} */
    TlThumbnail.prototype.emptyTemplate;
    /** @type {?} */
    TlThumbnail.prototype.clickThumbnail;
    /** @type {?} */
    TlThumbnail.prototype.clickDeleteThumbail;
    /**
     * @type {?}
     * @private
     */
    TlThumbnail.prototype.lightboxService;
    /**
     * @type {?}
     * @private
     */
    TlThumbnail.prototype.thumbnailService;
    /**
     * @type {?}
     * @private
     */
    TlThumbnail.prototype.dialogService;
}
//# sourceMappingURL=data:application/json;base64, 