import { Component, Input } from '@angular/core';
import { DocumentExtensionType } from '../../../../forms/page/common/widget-enums';
import _ from 'lodash';
import { AxoUtils } from '../../../../axo-utils/axo-utils';
import { AxDocument } from '../../../../forms/page/widgets/ax-document';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/material/icon";
function FormObjectDocumentValueComponent_ng_container_0_mat_icon_2_Template(rf, ctx) { if (rf & 1) {
    const _r12 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 4);
    i0.ɵɵlistener("click", function FormObjectDocumentValueComponent_ng_container_0_mat_icon_2_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r12); const ctx_r11 = i0.ɵɵnextContext(2); return ctx_r11.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_pdf1");
} }
function FormObjectDocumentValueComponent_ng_container_0_mat_icon_3_Template(rf, ctx) { if (rf & 1) {
    const _r14 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 4);
    i0.ɵɵlistener("click", function FormObjectDocumentValueComponent_ng_container_0_mat_icon_3_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r14); const ctx_r13 = i0.ɵɵnextContext(2); return ctx_r13.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_ppt");
} }
function FormObjectDocumentValueComponent_ng_container_0_mat_icon_4_Template(rf, ctx) { if (rf & 1) {
    const _r16 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 4);
    i0.ɵɵlistener("click", function FormObjectDocumentValueComponent_ng_container_0_mat_icon_4_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r16); const ctx_r15 = i0.ɵɵnextContext(2); return ctx_r15.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_pptx");
} }
function FormObjectDocumentValueComponent_ng_container_0_mat_icon_5_Template(rf, ctx) { if (rf & 1) {
    const _r18 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 4);
    i0.ɵɵlistener("click", function FormObjectDocumentValueComponent_ng_container_0_mat_icon_5_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r18); const ctx_r17 = i0.ɵɵnextContext(2); return ctx_r17.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_doc");
} }
function FormObjectDocumentValueComponent_ng_container_0_mat_icon_6_Template(rf, ctx) { if (rf & 1) {
    const _r20 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 4);
    i0.ɵɵlistener("click", function FormObjectDocumentValueComponent_ng_container_0_mat_icon_6_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r20); const ctx_r19 = i0.ɵɵnextContext(2); return ctx_r19.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_txt");
} }
function FormObjectDocumentValueComponent_ng_container_0_mat_icon_7_Template(rf, ctx) { if (rf & 1) {
    const _r22 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 4);
    i0.ɵɵlistener("click", function FormObjectDocumentValueComponent_ng_container_0_mat_icon_7_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r22); const ctx_r21 = i0.ɵɵnextContext(2); return ctx_r21.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_xls");
} }
function FormObjectDocumentValueComponent_ng_container_0_mat_icon_8_Template(rf, ctx) { if (rf & 1) {
    const _r24 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 4);
    i0.ɵɵlistener("click", function FormObjectDocumentValueComponent_ng_container_0_mat_icon_8_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r24); const ctx_r23 = i0.ɵɵnextContext(2); return ctx_r23.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_xlsx");
} }
function FormObjectDocumentValueComponent_ng_container_0_mat_icon_9_Template(rf, ctx) { if (rf & 1) {
    const _r26 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 4);
    i0.ɵɵlistener("click", function FormObjectDocumentValueComponent_ng_container_0_mat_icon_9_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r26); const ctx_r25 = i0.ɵɵnextContext(2); return ctx_r25.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_docx");
} }
function FormObjectDocumentValueComponent_ng_container_0_mat_icon_10_Template(rf, ctx) { if (rf & 1) {
    const _r28 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 4);
    i0.ɵɵlistener("click", function FormObjectDocumentValueComponent_ng_container_0_mat_icon_10_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r28); const ctx_r27 = i0.ɵɵnextContext(2); return ctx_r27.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_html");
} }
function FormObjectDocumentValueComponent_ng_container_0_mat_icon_11_Template(rf, ctx) { if (rf & 1) {
    const _r30 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 4);
    i0.ɵɵlistener("click", function FormObjectDocumentValueComponent_ng_container_0_mat_icon_11_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r30); const ctx_r29 = i0.ɵɵnextContext(2); return ctx_r29.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_file");
} }
function FormObjectDocumentValueComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementContainerStart(1, 1);
    i0.ɵɵtemplate(2, FormObjectDocumentValueComponent_ng_container_0_mat_icon_2_Template, 1, 1, "mat-icon", 2);
    i0.ɵɵtemplate(3, FormObjectDocumentValueComponent_ng_container_0_mat_icon_3_Template, 1, 1, "mat-icon", 2);
    i0.ɵɵtemplate(4, FormObjectDocumentValueComponent_ng_container_0_mat_icon_4_Template, 1, 1, "mat-icon", 2);
    i0.ɵɵtemplate(5, FormObjectDocumentValueComponent_ng_container_0_mat_icon_5_Template, 1, 1, "mat-icon", 2);
    i0.ɵɵtemplate(6, FormObjectDocumentValueComponent_ng_container_0_mat_icon_6_Template, 1, 1, "mat-icon", 2);
    i0.ɵɵtemplate(7, FormObjectDocumentValueComponent_ng_container_0_mat_icon_7_Template, 1, 1, "mat-icon", 2);
    i0.ɵɵtemplate(8, FormObjectDocumentValueComponent_ng_container_0_mat_icon_8_Template, 1, 1, "mat-icon", 2);
    i0.ɵɵtemplate(9, FormObjectDocumentValueComponent_ng_container_0_mat_icon_9_Template, 1, 1, "mat-icon", 2);
    i0.ɵɵtemplate(10, FormObjectDocumentValueComponent_ng_container_0_mat_icon_10_Template, 1, 1, "mat-icon", 2);
    i0.ɵɵtemplate(11, FormObjectDocumentValueComponent_ng_container_0_mat_icon_11_Template, 1, 1, "mat-icon", 3);
    i0.ɵɵelementContainerEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitch", ctx_r0.extension);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.pdf);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.ppt);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.pptx);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.document);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.txt);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.xls);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.xlsx);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.docx);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.html);
} }
export class FormObjectDocumentValueComponent {
    constructor() {
        this.documentType = Object.assign({}, DocumentExtensionType);
    }
    ngOnInit() {
        if (this.widget.values && !_.isEmpty(this.widget.values[0]?.path)) {
            this.widgetValue = this.widget.values[0];
            this.extension = this.widget.values[0].extension;
            this.widgetValue.path = AxoUtils.removeSlashFromImageUrl(this.widget.values[0]?.path);
        }
        else if (this.widget.value && !_.isEmpty(this.widget.value[0]?.name)) {
            this.widgetValue = this.widget.value[0];
            this.extension = this.widget.value[0].extension;
            this.widgetValue.name = AxoUtils.removeSlashFromImageUrl(this.widget.value[0]?.name);
            this.extension = AxoUtils.getDocumentExtension(this.widgetValue.name);
            this.widgetValue.path = '/images/media/app_data/' + this.widgetValue.name;
        }
    }
    downloadDocument() {
        window.open(this.baseUrl + this.widgetValue.path);
    }
}
FormObjectDocumentValueComponent.ɵfac = function FormObjectDocumentValueComponent_Factory(t) { return new (t || FormObjectDocumentValueComponent)(); };
FormObjectDocumentValueComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FormObjectDocumentValueComponent, selectors: [["app-formobject-document-value"]], inputs: { widget: "widget", baseUrl: "baseUrl" }, decls: 1, vars: 1, consts: [[4, "ngIf"], [3, "ngSwitch"], ["class", "full-width h-5 w-4", 3, "svgIcon", "click", 4, "ngSwitchCase"], ["class", "full-width h-5 w-4", 3, "svgIcon", "click", 4, "ngSwitchDefault"], [1, "full-width", "h-5", "w-4", 3, "svgIcon", "click"]], template: function FormObjectDocumentValueComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵtemplate(0, FormObjectDocumentValueComponent_ng_container_0_Template, 12, 10, "ng-container", 0);
    } if (rf & 2) {
        i0.ɵɵproperty("ngIf", ctx.widgetValue);
    } }, directives: [i1.NgIf, i1.NgSwitch, i1.NgSwitchCase, i1.NgSwitchDefault, i2.MatIcon], styles: [""] });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FormObjectDocumentValueComponent, [{
        type: Component,
        args: [{ selector: 'app-formobject-document-value', template: "<ng-container  *ngIf=\"widgetValue\">\n   <ng-container [ngSwitch]=\"extension\">\n    <mat-icon (click)=\"downloadDocument()\"  *ngSwitchCase = documentType.pdf class=\"full-width h-5 w-4\" [svgIcon]=\"'axo_pdf1'\">\n    </mat-icon>\n    \n    <mat-icon  (click)=\"downloadDocument()\" *ngSwitchCase=documentType.ppt class=\"full-width h-5 w-4\" [svgIcon]=\"'axo_ppt'\">\n    </mat-icon>\n    \n    <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase = documentType.pptx class=\"full-width h-5 w-4\" [svgIcon]=\"'axo_pptx'\">\n    </mat-icon>\n    \n    <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.document class=\"full-width h-5 w-4\" [svgIcon]=\"'axo_doc'\">\n    </mat-icon>\n    \n    <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.txt class=\"full-width h-5 w-4\" [svgIcon]=\"'axo_txt'\">\n    </mat-icon>\n    \n    <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.xls class=\"full-width h-5 w-4\" [svgIcon]=\"'axo_xls'\">\n    </mat-icon>\n    \n    <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase= documentType.xlsx class=\"full-width h-5 w-4\" [svgIcon]=\"'axo_xlsx'\">\n    </mat-icon>\n    \n    <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.docx class=\"full-width h-5 w-4\" [svgIcon]=\"'axo_docx'\">\n    </mat-icon>\n    \n    <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase= documentType.html class=\"full-width h-5 w-4\" [svgIcon]=\"'axo_html'\">\n    </mat-icon>\n\n    <mat-icon (click)=\"downloadDocument()\" *ngSwitchDefault class=\"full-width h-5 w-4\" [svgIcon]=\"'axo_file'\">\n    </mat-icon>\n</ng-container>\n</ng-container>\n", styles: [""] }]
    }], function () { return []; }, { widget: [{
            type: Input
        }], baseUrl: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 