import { Component, Input, ViewChild } from '@angular/core';
import { from, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import * as i0 from "@angular/core";
import * as i1 from "./thumbnail.service";
import * as i2 from "@angular/common";
export class ThumbnailComponent {
    thumbnailService;
    static nextId = 0;
    fallback = false;
    orientation = 0;
    imgEl = null;
    id = `s-thumbnail-${ThumbnailComponent.nextId++}`;
    size = 'medium';
    imageSource;
    imageFallback;
    imageAlt;
    iconClass = 'far fa-image';
    hasAction = false;
    actionIconClass = 'fas fa-camera';
    isTile = false;
    isBrand = false;
    ngUnsubscribe = new Subject();
    constructor(thumbnailService) {
        this.thumbnailService = thumbnailService;
    }
    ngOnDestroy() {
        this.ngUnsubscribe.next();
        this.ngUnsubscribe.complete();
    }
    ngAfterViewInit() {
        if (this.imgEl) {
            this.imgEl.nativeElement.addEventListener('load', () => {
                from(this.thumbnailService.getBinaryFile(this.imgEl?.nativeElement))
                    .pipe(takeUntil(this.ngUnsubscribe))
                    .subscribe((value) => {
                    if (typeof value === 'number') {
                        this.orientation = value;
                    }
                    else {
                        console.error('Valor retornado não é um número:', value);
                    }
                });
            });
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ThumbnailComponent, deps: [{ token: i1.ThumbnailService }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ThumbnailComponent, selector: "s-thumbnail", inputs: { id: "id", size: "size", imageSource: "imageSource", imageFallback: "imageFallback", imageAlt: "imageAlt", iconClass: "iconClass", hasAction: "hasAction", actionIconClass: "actionIconClass", isTile: "isTile", isBrand: "isBrand" }, viewQueries: [{ propertyName: "imgEl", first: true, predicate: ["img"], descendants: true }], ngImport: i0, template: "<div\n    [id]=\"id\"\n    class=\"thumbnail-container thumbnail-container--{{ size }}\"\n    [ngClass]=\"{\n        'thumbnail-container--with-action': hasAction,\n        'thumbnail-container--brand': isBrand,\n    }\"\n>\n    @if (imageSource || imageFallback) {\n        <div\n            [id]=\"id + '-image-container'\"\n            class=\"image-container\"\n            [ngClass]=\"{\n                'image-container--rounded': !isBrand,\n            }\"\n        >\n            @if (!fallback) {\n                <img\n                    #img\n                    [id]=\"id + '-image'\"\n                    (error)=\"fallback = true\"\n                    [src]=\"imageSource\"\n                    [alt]=\"imageAlt\"\n                    [ngClass]=\"{\n                        smallThumbnail: isTile,\n                        'exif-orientation-2': orientation === 2,\n                        'exif-orientation-3': orientation === 3,\n                        'exif-orientation-4': orientation === 4,\n                        'exif-orientation-5': orientation === 5,\n                        'exif-orientation-6': orientation === 6,\n                        'exif-orientation-7': orientation === 7,\n                        'exif-orientation-8': orientation === 8,\n                    }\"\n                />\n            }\n\n            @if (fallback && imageFallback) {\n                <img\n                    #img\n                    [id]=\"id + '-image-fallback'\"\n                    (error)=\"imageFallback = undefined\"\n                    [src]=\"imageFallback\"\n                    [alt]=\"imageAlt\"\n                    [ngClass]=\"{\n                        smallThumbnail: isTile,\n                        'exif-orientation-2': orientation === 2,\n                        'exif-orientation-3': orientation === 3,\n                        'exif-orientation-4': orientation === 4,\n                        'exif-orientation-5': orientation === 5,\n                        'exif-orientation-6': orientation === 6,\n                        'exif-orientation-7': orientation === 7,\n                        'exif-orientation-8': orientation === 8,\n                    }\"\n                />\n            }\n\n            @if (fallback && !imageFallback) {\n                <i class=\"fallback-img-color far fa-image\"> </i>\n            }\n        </div>\n    }\n\n    @if (hasAction) {\n        <div\n            [id]=\"id + '-action-icon-container'\"\n            class=\"action-icon-container action-icon-container--{{ size }}\"\n        >\n            <span\n                [id]=\"id + '-action-icon'\"\n                [class]=\"actionIconClass\"\n                aria-hidden=\"true\"\n            >\n            </span>\n        </div>\n    }\n\n    @if (!imageSource && !imageFallback) {\n        <div\n            [id]=\"id + '-icon-container'\"\n            class=\"icon-container icon-container--{{ size }}\"\n            [ngClass]=\"{ 'image-container--rounded': !isBrand }\"\n        >\n            <span\n                [id]=\"id + '-icon'\"\n                [class]=\"iconClass\"\n                aria-hidden=\"true\"\n            >\n            </span>\n        </div>\n    }\n\n    <ng-content></ng-content>\n</div>\n", styles: [":host{display:inline-block}.thumbnail-container{color:#fff;position:relative;text-align:center}.thumbnail-container--large{font-size:50px;height:100px;width:100px}.thumbnail-container--large.thumbnail-container--brand{width:200px}.thumbnail-container--medium{font-size:40px;height:70px;width:70px}.thumbnail-container--medium.thumbnail-container--brand{width:140px}.thumbnail-container--small{font-size:22px;height:40px;width:40px}.thumbnail-container--small.thumbnail-container--brand{width:80px}.thumbnail-container--with-action{cursor:pointer}.action-icon-container{background-color:#428bca;border-radius:50%;bottom:0;position:absolute;right:0}.action-icon-container--large,.action-icon-container--medium{font-size:10pt;height:25px;padding:3px;width:25px}.action-icon-container--small{font-size:6pt;height:16px;padding:2px;width:16px}.icon-container,.image-container{align-items:center;height:100%;overflow:hidden;width:100%}.icon-container--rounded,.image-container--rounded{border-radius:50%}.smallThumbnail{height:40px!important}.icon-container{background-color:#ccc;color:#fff}.icon-container--large{line-height:98px}.icon-container--medium{line-height:68px}.icon-container--small{line-height:38px}.image-container{align-items:center;background-color:#ccc;display:flex;justify-content:center}.image-container img{width:100%}.image-container img.exif-orientation-2{transform:rotateY(180deg)}.image-container img.exif-orientation-3{transform:rotate(180deg)}.image-container img.exif-orientation-4{transform:rotate(180deg) rotateY(180deg)}.image-container img.exif-orientation-5{transform:rotate(270deg) rotateY(180deg)}.image-container img.exif-orientation-6{transform:rotate(90deg)}.image-container img.exif-orientation-7{transform:rotate(90deg) rotateY(180deg)}.image-container img.exif-orientation-8{transform:rotate(270deg)}.fallback-img-color{color:#fff}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ThumbnailComponent, decorators: [{
            type: Component,
            args: [{ selector: 's-thumbnail', template: "<div\n    [id]=\"id\"\n    class=\"thumbnail-container thumbnail-container--{{ size }}\"\n    [ngClass]=\"{\n        'thumbnail-container--with-action': hasAction,\n        'thumbnail-container--brand': isBrand,\n    }\"\n>\n    @if (imageSource || imageFallback) {\n        <div\n            [id]=\"id + '-image-container'\"\n            class=\"image-container\"\n            [ngClass]=\"{\n                'image-container--rounded': !isBrand,\n            }\"\n        >\n            @if (!fallback) {\n                <img\n                    #img\n                    [id]=\"id + '-image'\"\n                    (error)=\"fallback = true\"\n                    [src]=\"imageSource\"\n                    [alt]=\"imageAlt\"\n                    [ngClass]=\"{\n                        smallThumbnail: isTile,\n                        'exif-orientation-2': orientation === 2,\n                        'exif-orientation-3': orientation === 3,\n                        'exif-orientation-4': orientation === 4,\n                        'exif-orientation-5': orientation === 5,\n                        'exif-orientation-6': orientation === 6,\n                        'exif-orientation-7': orientation === 7,\n                        'exif-orientation-8': orientation === 8,\n                    }\"\n                />\n            }\n\n            @if (fallback && imageFallback) {\n                <img\n                    #img\n                    [id]=\"id + '-image-fallback'\"\n                    (error)=\"imageFallback = undefined\"\n                    [src]=\"imageFallback\"\n                    [alt]=\"imageAlt\"\n                    [ngClass]=\"{\n                        smallThumbnail: isTile,\n                        'exif-orientation-2': orientation === 2,\n                        'exif-orientation-3': orientation === 3,\n                        'exif-orientation-4': orientation === 4,\n                        'exif-orientation-5': orientation === 5,\n                        'exif-orientation-6': orientation === 6,\n                        'exif-orientation-7': orientation === 7,\n                        'exif-orientation-8': orientation === 8,\n                    }\"\n                />\n            }\n\n            @if (fallback && !imageFallback) {\n                <i class=\"fallback-img-color far fa-image\"> </i>\n            }\n        </div>\n    }\n\n    @if (hasAction) {\n        <div\n            [id]=\"id + '-action-icon-container'\"\n            class=\"action-icon-container action-icon-container--{{ size }}\"\n        >\n            <span\n                [id]=\"id + '-action-icon'\"\n                [class]=\"actionIconClass\"\n                aria-hidden=\"true\"\n            >\n            </span>\n        </div>\n    }\n\n    @if (!imageSource && !imageFallback) {\n        <div\n            [id]=\"id + '-icon-container'\"\n            class=\"icon-container icon-container--{{ size }}\"\n            [ngClass]=\"{ 'image-container--rounded': !isBrand }\"\n        >\n            <span\n                [id]=\"id + '-icon'\"\n                [class]=\"iconClass\"\n                aria-hidden=\"true\"\n            >\n            </span>\n        </div>\n    }\n\n    <ng-content></ng-content>\n</div>\n", styles: [":host{display:inline-block}.thumbnail-container{color:#fff;position:relative;text-align:center}.thumbnail-container--large{font-size:50px;height:100px;width:100px}.thumbnail-container--large.thumbnail-container--brand{width:200px}.thumbnail-container--medium{font-size:40px;height:70px;width:70px}.thumbnail-container--medium.thumbnail-container--brand{width:140px}.thumbnail-container--small{font-size:22px;height:40px;width:40px}.thumbnail-container--small.thumbnail-container--brand{width:80px}.thumbnail-container--with-action{cursor:pointer}.action-icon-container{background-color:#428bca;border-radius:50%;bottom:0;position:absolute;right:0}.action-icon-container--large,.action-icon-container--medium{font-size:10pt;height:25px;padding:3px;width:25px}.action-icon-container--small{font-size:6pt;height:16px;padding:2px;width:16px}.icon-container,.image-container{align-items:center;height:100%;overflow:hidden;width:100%}.icon-container--rounded,.image-container--rounded{border-radius:50%}.smallThumbnail{height:40px!important}.icon-container{background-color:#ccc;color:#fff}.icon-container--large{line-height:98px}.icon-container--medium{line-height:68px}.icon-container--small{line-height:38px}.image-container{align-items:center;background-color:#ccc;display:flex;justify-content:center}.image-container img{width:100%}.image-container img.exif-orientation-2{transform:rotateY(180deg)}.image-container img.exif-orientation-3{transform:rotate(180deg)}.image-container img.exif-orientation-4{transform:rotate(180deg) rotateY(180deg)}.image-container img.exif-orientation-5{transform:rotate(270deg) rotateY(180deg)}.image-container img.exif-orientation-6{transform:rotate(90deg)}.image-container img.exif-orientation-7{transform:rotate(90deg) rotateY(180deg)}.image-container img.exif-orientation-8{transform:rotate(270deg)}.fallback-img-color{color:#fff}\n"] }]
        }], ctorParameters: () => [{ type: i1.ThumbnailService }], propDecorators: { imgEl: [{
                type: ViewChild,
                args: ['img', { static: false }]
            }], id: [{
                type: Input
            }], size: [{
                type: Input
            }], imageSource: [{
                type: Input
            }], imageFallback: [{
                type: Input
            }], imageAlt: [{
                type: Input
            }], iconClass: [{
                type: Input
            }], hasAction: [{
                type: Input
            }], actionIconClass: [{
                type: Input
            }], isTile: [{
                type: Input
            }], isBrand: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 