import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { MatMenu } from '@angular/material/menu';
import { FileConversionTypes } from '../models/file-conversion-types.model';
import { FileCategory } from '../services/api/models/file-category.model';
import * as i0 from "@angular/core";
import * as i1 from "../../tld-common/services";
import * as i2 from "@angular/common";
import * as i3 from "@ngbracket/ngx-layout/flex";
import * as i4 from "@angular/material/button";
import * as i5 from "@angular/material/menu";
import * as i6 from "@angular/material/icon";
import * as i7 from "@angular/material/tooltip";
import * as i8 from "@ngx-translate/core";
export class TldTranslateFileDownloadButtonComponent {
    config;
    isAuth;
    get showSourceDownloadPdf() {
        return this.sourceDownload &&
            this.file?.sourceFileName &&
            this.config.fileConfig.allowPDFSourceDownload &&
            this.file.fileType == FileConversionTypes.PDF;
    }
    get showSourceDownloadImage() {
        return this.sourceDownload &&
            this.file?.sourceFileName &&
            this.config.fileConfig.allowImageSourceDownload &&
            this.file.fileType == FileConversionTypes.IMAGE;
    }
    get extensions() { return this.file?.availableExtensions || []; }
    translatedCategory = FileCategory.TRANSLATED;
    menu;
    tldClick = new EventEmitter();
    file;
    //@Input() extensions: ITranslationExtensionMeta[];
    disabled;
    sourceDownload;
    constructor(config) {
        this.config = config;
    }
    ngOnInit() {
        this.isAuth = this.config.coreConfig.isAuth;
    }
    onClick(meta) {
        if (!meta && this.extensions) {
            meta = this.extensions.find((file) => file.category === FileCategory.TRANSLATED) ?? this.extensions[0];
        }
        this.tldClick.emit(meta);
    }
    onSourceClick() {
        const sourceMeta = this.extensions.find(extension => extension.category === FileCategory.SOURCECONVERTED);
        this.onClick(sourceMeta);
    }
    onMenuOpen() {
        const panel = document.getElementById(this.menu.panelId);
        panel.setAttribute("data-test-id", 'tld-download-file-list');
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TldTranslateFileDownloadButtonComponent, deps: [{ token: i1.TldTranslateConfigService }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: TldTranslateFileDownloadButtonComponent, selector: "tld-translate-file-download-button", inputs: { file: "file", disabled: "disabled", sourceDownload: "sourceDownload" }, outputs: { tldClick: "tldClick" }, viewQueries: [{ propertyName: "menu", first: true, predicate: MatMenu, descendants: true }], ngImport: i0, template: "<div fxLayout=\"row\">\r\n\t<button\r\n\t\t*ngIf=\"!showSourceDownloadPdf && !showSourceDownloadImage\"\r\n\t\tmat-icon-button\r\n\t\tclass=\"action-button border-accent download-button\"\r\n\t\t[matTooltip]=\"'TLD_TRANSLATE.DOWNLOAD_TRANSLATED' | translate\"\r\n\t\t[disabled]=\"disabled\"\r\n\t\t(click)=\"onClick()\"\r\n\t>\r\n\t\t<mat-icon [svgIcon]=\"'download'\"></mat-icon>\r\n\t</button>\r\n\r\n\t<button\r\n\t\t#menuTrigger=\"matMenuTrigger\"\r\n\t\t*ngIf=\"extensions?.length && (showSourceDownloadPdf || showSourceDownloadImage)\"\r\n\t\tmat-icon-button\r\n\t\tcolor=\"accent\"\r\n\t\tfxLayoutAlign=\"center center\"\r\n\t\tdata-test-id=\"download-other-formats-button\"\r\n\t\t[matMenuTriggerFor]=\"extensionMenu\"\r\n\t\t[disabled]=\"disabled\"\r\n\t\t[attr.aria-label]=\"'ARIA_LABELS.SHOW_EXTENSIONS' | translate\"\r\n\t\t[matTooltip]=\"'TLD_TRANSLATE.DOWNLOAD_TRANSLATED' | translate\"\r\n\t\t(menuOpened)=\"onMenuOpen()\"\r\n\t>\r\n\t\t<mat-icon [svgIcon]=\"'download'\"></mat-icon>\r\n\t</button>\r\n</div>\r\n<mat-menu #extensionMenu=\"matMenu\">\r\n\t<div fxLayout=\"column\">\r\n\t\t<ng-container *ngFor=\"let extension of extensions\">\r\n\t\t\t<button mat-menu-item fxLayoutAlign=\"start center\" class=\"language-title\" *ngIf=\"extension.category === translatedCategory\" (click)=\"onClick(extension)\">\r\n\t\t\t\t{{ 'TLD_TRANSLATE.SUGGEST_TRANSLATION_LABEL' | translate }} ({{ extension.extension }})\r\n\t\t\t</button>\r\n\t\t</ng-container>\r\n\t\t<button mat-menu-item fxLayoutAlign=\"start center\" *ngIf=\"showSourceDownloadPdf\" class=\"language-title\" (click)=\"onSourceClick()\">\r\n\t\t\t{{ \"TLD_TRANSLATE.FILE_DOWNLOAD_SOURCE\" | translate }}\r\n\t\t</button>\r\n\t\t<button mat-menu-item fxLayoutAlign=\"start center\" *ngIf=\"showSourceDownloadImage\" class=\"language-title\" (click)=\"onSourceClick()\">\r\n\t\t\t{{ \"TLD_TRANSLATE.FILE_DOWNLOAD_SOURCE_IMAGE\" | translate }}\r\n\t\t</button>\r\n\t</div>\r\n</mat-menu>\r\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.DefaultLayoutDirective, selector: "  [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md],  [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md],  [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm],  [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i3.DefaultLayoutAlignDirective, selector: "  [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md],  [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md],  [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm],  [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { kind: "component", type: i4.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i5.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i5.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i5.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i7.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "pipe", type: i8.TranslatePipe, name: "translate" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TldTranslateFileDownloadButtonComponent, decorators: [{
            type: Component,
            args: [{ selector: 'tld-translate-file-download-button', template: "<div fxLayout=\"row\">\r\n\t<button\r\n\t\t*ngIf=\"!showSourceDownloadPdf && !showSourceDownloadImage\"\r\n\t\tmat-icon-button\r\n\t\tclass=\"action-button border-accent download-button\"\r\n\t\t[matTooltip]=\"'TLD_TRANSLATE.DOWNLOAD_TRANSLATED' | translate\"\r\n\t\t[disabled]=\"disabled\"\r\n\t\t(click)=\"onClick()\"\r\n\t>\r\n\t\t<mat-icon [svgIcon]=\"'download'\"></mat-icon>\r\n\t</button>\r\n\r\n\t<button\r\n\t\t#menuTrigger=\"matMenuTrigger\"\r\n\t\t*ngIf=\"extensions?.length && (showSourceDownloadPdf || showSourceDownloadImage)\"\r\n\t\tmat-icon-button\r\n\t\tcolor=\"accent\"\r\n\t\tfxLayoutAlign=\"center center\"\r\n\t\tdata-test-id=\"download-other-formats-button\"\r\n\t\t[matMenuTriggerFor]=\"extensionMenu\"\r\n\t\t[disabled]=\"disabled\"\r\n\t\t[attr.aria-label]=\"'ARIA_LABELS.SHOW_EXTENSIONS' | translate\"\r\n\t\t[matTooltip]=\"'TLD_TRANSLATE.DOWNLOAD_TRANSLATED' | translate\"\r\n\t\t(menuOpened)=\"onMenuOpen()\"\r\n\t>\r\n\t\t<mat-icon [svgIcon]=\"'download'\"></mat-icon>\r\n\t</button>\r\n</div>\r\n<mat-menu #extensionMenu=\"matMenu\">\r\n\t<div fxLayout=\"column\">\r\n\t\t<ng-container *ngFor=\"let extension of extensions\">\r\n\t\t\t<button mat-menu-item fxLayoutAlign=\"start center\" class=\"language-title\" *ngIf=\"extension.category === translatedCategory\" (click)=\"onClick(extension)\">\r\n\t\t\t\t{{ 'TLD_TRANSLATE.SUGGEST_TRANSLATION_LABEL' | translate }} ({{ extension.extension }})\r\n\t\t\t</button>\r\n\t\t</ng-container>\r\n\t\t<button mat-menu-item fxLayoutAlign=\"start center\" *ngIf=\"showSourceDownloadPdf\" class=\"language-title\" (click)=\"onSourceClick()\">\r\n\t\t\t{{ \"TLD_TRANSLATE.FILE_DOWNLOAD_SOURCE\" | translate }}\r\n\t\t</button>\r\n\t\t<button mat-menu-item fxLayoutAlign=\"start center\" *ngIf=\"showSourceDownloadImage\" class=\"language-title\" (click)=\"onSourceClick()\">\r\n\t\t\t{{ \"TLD_TRANSLATE.FILE_DOWNLOAD_SOURCE_IMAGE\" | translate }}\r\n\t\t</button>\r\n\t</div>\r\n</mat-menu>\r\n" }]
        }], ctorParameters: () => [{ type: i1.TldTranslateConfigService }], propDecorators: { menu: [{
                type: ViewChild,
                args: [MatMenu]
            }], tldClick: [{
                type: Output
            }], file: [{
                type: Input
            }], disabled: [{
                type: Input
            }], sourceDownload: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 