import { TaskStatus } from './../../data-view-lib/data-view/task';
import { ScreenType } from './../../enlighten-lib/filters/condition-type';
import { Component, Input, ViewEncapsulation } from '@angular/core';
import { Subject } from 'rxjs';
import { SectionChildType, SectionType } from '../../forms/page/common/widget-enums';
import { DataDetailViewDto } from './data-detail-view-dto';
import { GhostLoaderType } from '../../ghost-loader/ghost-loader.component';
import * as i0 from "@angular/core";
function FormObjectViewComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "app-ghost-loader", 1);
    i0.ɵɵelement(2, "app-ghost-loader", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("elementType", ctx_r0.GhostLoaderType.SubHeaderLoader);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("elementType", ctx_r0.GhostLoaderType.DataDetailLoader);
} }
function FormObjectViewComponent_ng_container_1_div_2_Template(rf, ctx) { if (rf & 1) {
    const _r6 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵelementStart(1, "div", 9);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 10);
    i0.ɵɵlistener("click", function FormObjectViewComponent_ng_container_1_div_2_Template_div_click_3_listener() { i0.ɵɵrestoreView(_r6); const ctx_r5 = i0.ɵɵnextContext(2); return ctx_r5.redirectToTasks(ctx_r5.dataDetailView.formObject.name); });
    i0.ɵɵtext(4, "History ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r2.dataDetailView.formObject.name, " ");
} }
function FormObjectViewComponent_ng_container_1_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵelementStart(1, "div", 12);
    i0.ɵɵelementStart(2, "h2", 13);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(ctx_r3.dataDetailView == null ? null : ctx_r3.dataDetailView.formObject == null ? null : ctx_r3.dataDetailView.formObject.title);
} }
function FormObjectViewComponent_ng_container_1_div_5_div_1_ng_container_1_ng_container_1_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 18);
    i0.ɵɵtext(2, "This task is in progress");
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} }
function FormObjectViewComponent_ng_container_1_div_5_div_1_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "app-meta-section", 16);
    i0.ɵɵelementStart(2, "div", 17);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(4, FormObjectViewComponent_ng_container_1_div_5_div_1_ng_container_1_ng_container_1_ng_container_4_Template, 3, 0, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const section_r7 = i0.ɵɵnextContext(3).$implicit;
    const ctx_r11 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("taskDetailsMap", ctx_r11.taskDetailsMap)("section", section_r7);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r11.taskDetailsMap["{_Description_}"] ? ctx_r11.taskDetailsMap["{_Description_}"][0] : "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r11.taskStatus == ctx_r11.TaskStatus.todo || ctx_r11.taskStatus == ctx_r11.TaskStatus.overdue);
} }
function FormObjectViewComponent_ng_container_1_div_5_div_1_ng_container_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "app-section-view", 19);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const section_r7 = i0.ɵɵnextContext(3).$implicit;
    const ctx_r12 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("section", section_r7)("formObjectId", ctx_r12.dataDetailView == null ? null : ctx_r12.dataDetailView.formObject == null ? null : ctx_r12.dataDetailView.formObject.id)("baseUrl", ctx_r12.baseUrl)("axonatorX1Url", ctx_r12.axonatorX1Url);
} }
function FormObjectViewComponent_ng_container_1_div_5_div_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, FormObjectViewComponent_ng_container_1_div_5_div_1_ng_container_1_ng_container_1_Template, 5, 4, "ng-container", 0);
    i0.ɵɵtemplate(2, FormObjectViewComponent_ng_container_1_div_5_div_1_ng_container_1_ng_container_2_Template, 2, 4, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const section_r7 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r9 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", section_r7.sectionChildType == ctx_r9.SectionChildType.meta);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r9.dataDetailView && section_r7.sectionChildType == ctx_r9.SectionChildType.widgetSection && ctx_r9.taskStatus == ctx_r9.TaskStatus.done);
} }
function FormObjectViewComponent_ng_container_1_div_5_div_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "app-section-view", 19);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const section_r7 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r10 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("section", section_r7)("formObjectId", ctx_r10.dataDetailView.formObject.id)("baseUrl", ctx_r10.baseUrl)("axonatorX1Url", ctx_r10.axonatorX1Url);
} }
function FormObjectViewComponent_ng_container_1_div_5_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtemplate(1, FormObjectViewComponent_ng_container_1_div_5_div_1_ng_container_1_Template, 3, 2, "ng-container", 0);
    i0.ɵɵtemplate(2, FormObjectViewComponent_ng_container_1_div_5_div_1_ng_container_2_Template, 2, 4, "ng-container", 0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r8 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.ScreenType == ctx_r8.screenType.TaskDetailView && ctx_r8.taskDetailsMap);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.ScreenType != ctx_r8.screenType.TaskDetailView);
} }
function FormObjectViewComponent_ng_container_1_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtemplate(1, FormObjectViewComponent_ng_container_1_div_5_div_1_Template, 3, 2, "div", 14);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const section_r7 = ctx.$implicit;
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", section_r7.type === ctx_r4.sectionType.section);
} }
function FormObjectViewComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 3);
    i0.ɵɵtemplate(2, FormObjectViewComponent_ng_container_1_div_2_Template, 5, 1, "div", 4);
    i0.ɵɵtemplate(3, FormObjectViewComponent_ng_container_1_div_3_Template, 4, 1, "div", 5);
    i0.ɵɵelementStart(4, "div", 6);
    i0.ɵɵtemplate(5, FormObjectViewComponent_ng_container_1_div_5_Template, 2, 1, "div", 7);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r1.showHeader && !ctx_r1.taskDetailsMap);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.dataDetailView == null ? null : ctx_r1.dataDetailView.formObject == null ? null : ctx_r1.dataDetailView.formObject.title);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", ctx_r1.dataDetailView == null ? null : ctx_r1.dataDetailView.sections);
} }
export class FormObjectViewComponent {
    constructor() {
        this.showHeader = true;
        this.ScreenType = null;
        this.sectionType = Object.assign({}, SectionType);
        this.GhostLoaderType = GhostLoaderType;
        /*
         * Subject object which helps unsubscribe all the subscribed objects in the component
         */
        this._unsubscribeAll = new Subject();
    }
    /**
     * On init
     */
    ngOnInit() {
        this.showGhostLoader = false;
    }
    /**
     * SectionChildType enum
     */
    get SectionChildType() {
        return SectionChildType;
    }
    /**
     * ScreenType enum
     */
    get screenType() {
        return ScreenType;
    }
    /**
     * Task Status enum
     */
    get TaskStatus() {
        return TaskStatus;
    }
    //AXE-I6556
    //formId and fornObjectId is set in url and redirected to Task View
    redirectToTasks(name) {
        let leftMenuItems = JSON.parse(localStorage.getItem("leftMenuItems")) || [];
        let currentUrl = window.location.href;
        let urlParts = currentUrl.split('/');
        let foid = urlParts[urlParts.length - 1];
        let formIdMatch = currentUrl.match(/forms\/(\d+)/);
        let formId = formIdMatch ? formIdMatch[1] : '';
        let parts = currentUrl.split('forms');
        let baseUrl = parts[0];
        leftMenuItems.forEach(item => {
            if (item.subType === "TaskView") {
                let appendUrl = baseUrl + item.link + "?foid=" + foid + "&fid=" + formId;
                window.location.href = appendUrl;
            }
        });
    }
}
FormObjectViewComponent.ɵfac = function FormObjectViewComponent_Factory(t) { return new (t || FormObjectViewComponent)(); };
FormObjectViewComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FormObjectViewComponent, selectors: [["lib-form-object-view"]], inputs: { form: "form", dataDetailView: "dataDetailView", baseUrl: "baseUrl", axonatorX1Url: "axonatorX1Url", showHeader: "showHeader", ScreenType: "ScreenType", taskDetailsMap: "taskDetailsMap", taskStatus: "taskStatus", showGhostLoader: "showGhostLoader" }, decls: 2, vars: 2, consts: [[4, "ngIf"], [1, "h-12", 3, "elementType"], [3, "elementType"], [1, "form-object-view", "w-full", "border-box"], ["class", "subheader w-full flex justify-between items-center sm:flex hidden", 4, "ngIf"], ["class", "flex items-center", 4, "ngIf"], [1, "sm:px-10", "px-3", "mt-8", "mb-4", "data-detail-content"], [4, "ngFor", "ngForOf"], [1, "subheader", "w-full", "flex", "justify-between", "items-center", "sm:flex", "hidden"], [1, "text-3xl"], [1, "mr-3", "px-3", "py-1", "rounded-2xl", "text-white", "text-base", "bg-blue", "font-medium", "cursor-pointer", 3, "click"], [1, "flex", "items-center"], [1, "flex", "items-center", "justify-between", "mx-auto", "h-12", "w-full", "bg-white", "form-object-view-heading"], [1, "leading-tight", "pl-10"], ["class", "border-box", 4, "ngIf"], [1, "border-box"], [3, "taskDetailsMap", "section"], [1, "task-list-discription-title"], [1, "task-status-message"], [3, "section", "formObjectId", "baseUrl", "axonatorX1Url"]], template: function FormObjectViewComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵtemplate(0, FormObjectViewComponent_ng_container_0_Template, 3, 2, "ng-container", 0);
        i0.ɵɵtemplate(1, FormObjectViewComponent_ng_container_1_Template, 6, 3, "ng-container", 0);
    } if (rf & 2) {
        i0.ɵɵproperty("ngIf", ctx.showGhostLoader);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.showGhostLoader);
    } }, styles: [".form-object-view{background-color:#fcfdff}.form-object-view .form-object-view-heading{border-bottom:.5px solid #cccccc7d}.form-object-view .form-object-view-heading h2{font-family:Roboto,sans-serif;font-weight:400;font-size:18px;line-height:21px;color:#10172b;margin:0}.form-object-view .icon-container{height:1.5rem!important;min-height:1.5rem!important;width:1.5rem!important;min-width:1.5rem!important;display:flex}.form-object-view .icon-container .location-btn-icon{background:#E1E7EF;padding:.3rem .2rem;cursor:pointer}.form-object-view .icon-container .location-btn-icon mat-icon{height:.875rem!important;min-height:.875rem!important;width:.875rem!important;min-width:.875rem!important}.form-object-view .bg-blue{background-image:linear-gradient(to right,#4E4AEA,#3C88FC)}.capture-data{padding-top:30px}.capture-data h3{margin-bottom:5px!important}.capture-data .capture-data-detail{color:#10172b;border:.3px solid #CFD4E3;box-sizing:border-box}.capture-data .capture-data-detail .capture-data-container{margin:auto!important}.capture-data .capture-data-detail .capture-data-container .mat-icon{height:60px;width:60px;min-width:60px;min-height:60px}.capture-data .capture-data-detail .capture-data-name{font-size:10px}.cdk-drag-preview{box-sizing:border-box;border-radius:4px;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.example-list.cdk-drop-list-dragging .example-box:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}.mat-card{box-shadow:none!important;background:#FFFFFF;border:.5px solid #DCDCDC;border-radius:4px;padding:1rem!important;margin-bottom:1rem;align-items:center!important;min-width:100%}.mat-card .data-detail-info .data-detail-title{margin:0!important}@media screen and (max-width: 768px){dynamic-data-view .data-detail-content{margin:0!important}dynamic-data-view .data-detail-content .mat-card{padding:.8rem!important}.mat-card{padding:.8rem!important}}\n"], encapsulation: 2 });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FormObjectViewComponent, [{
        type: Component,
        args: [{ selector: 'lib-form-object-view', encapsulation: ViewEncapsulation.None, template: "<ng-container *ngIf=\"showGhostLoader\">\n    <app-ghost-loader [elementType]=\"GhostLoaderType.SubHeaderLoader\" class=\"h-12\"></app-ghost-loader>\n    <app-ghost-loader [elementType]=\"GhostLoaderType.DataDetailLoader\"></app-ghost-loader>\n</ng-container>\n<ng-container *ngIf=\"!showGhostLoader\"> \n    <div class=\"form-object-view w-full border-box\">\n        <div class=\"subheader w-full flex justify-between items-center sm:flex hidden\"\n            *ngIf=\"showHeader && !taskDetailsMap\">\n            <div class=\"text-3xl\">\n                {{dataDetailView.formObject.name}}\n            </div>\n            <div class=\"mr-3 px-3 py-1 rounded-2xl text-white text-base bg-blue font-medium cursor-pointer\"\n                (click)=\"redirectToTasks(dataDetailView.formObject.name)\">History\n            </div>\n        </div>\n        <!-- form object view heading start-->\n        <div class=\"flex items-center\" *ngIf=\"dataDetailView?.formObject?.title\">\n            <div class=\"flex items-center justify-between mx-auto h-12 w-full bg-white form-object-view-heading\">\n                <h2 class=\"leading-tight pl-10\">{{dataDetailView?.formObject?.title}}</h2>\n            </div>\n        </div>\n        <div class=\"sm:px-10 px-3 mt-8 mb-4 data-detail-content\">\n            <!-- here we will rendering the page fields dynamically using component factory resolver -->\n        <div *ngFor=\"let section of dataDetailView?.sections\">\n            <div *ngIf=\"section.type === sectionType.section\" class=\"border-box\">\n\n            <!-- checks the screen type is task view or not  -->\n            <ng-container *ngIf=\"ScreenType == screenType.TaskDetailView && taskDetailsMap\">\n                <!-- checks the section is a meta section or not -->\n                <ng-container *ngIf=\"section.sectionChildType == SectionChildType.meta\">\n                    <!-- meta section rendering -->\n                    <app-meta-section [taskDetailsMap]=\"taskDetailsMap\" [section]=\"section\"></app-meta-section>\n\n                        <!-- task description -->\n                        <div class=\"task-list-discription-title\">{{taskDetailsMap[\"{_Description_}\"]?taskDetailsMap[\"{_Description_}\"][0]:''}}</div>\n                        <!-- does not display details of form if the task is todo or delivered -->\n                        <ng-container *ngIf=\"taskStatus == TaskStatus.todo || taskStatus == TaskStatus.overdue\">\n                            <div class=\"task-status-message\" >This task is in progress</div>\n                        </ng-container>\n                    </ng-container>\n\n                    <!-- widget section rendering in task detail view-->\n                    <!-- display details of form if the task is done -->\n                    <ng-container *ngIf=\"dataDetailView && section.sectionChildType == SectionChildType.widgetSection && taskStatus == TaskStatus.done\">\n                        <app-section-view  [section]=\"section\" [formObjectId] = \"dataDetailView?.formObject?.id\" [baseUrl] =\"baseUrl\" [axonatorX1Url] =\"axonatorX1Url\"></app-section-view>\n                    </ng-container>\n                </ng-container>\n\n\n                <!-- widget section rendering in data detail view.-->\n                <ng-container *ngIf=\"ScreenType != screenType.TaskDetailView\">\n                    <app-section-view  [section]=\"section\" [formObjectId] = \"dataDetailView.formObject.id\" [baseUrl] =\"baseUrl\" [axonatorX1Url] =\"axonatorX1Url\"></app-section-view>\n                </ng-container>\n            </div>\n        </div>\n        </div>\n    </div>\n</ng-container>\n", styles: [".form-object-view{background-color:#fcfdff}.form-object-view .form-object-view-heading{border-bottom:.5px solid #cccccc7d}.form-object-view .form-object-view-heading h2{font-family:Roboto,sans-serif;font-weight:400;font-size:18px;line-height:21px;color:#10172b;margin:0}.form-object-view .icon-container{height:1.5rem!important;min-height:1.5rem!important;width:1.5rem!important;min-width:1.5rem!important;display:flex}.form-object-view .icon-container .location-btn-icon{background:#E1E7EF;padding:.3rem .2rem;cursor:pointer}.form-object-view .icon-container .location-btn-icon mat-icon{height:.875rem!important;min-height:.875rem!important;width:.875rem!important;min-width:.875rem!important}.form-object-view .bg-blue{background-image:linear-gradient(to right,#4E4AEA,#3C88FC)}.capture-data{padding-top:30px}.capture-data h3{margin-bottom:5px!important}.capture-data .capture-data-detail{color:#10172b;border:.3px solid #CFD4E3;box-sizing:border-box}.capture-data .capture-data-detail .capture-data-container{margin:auto!important}.capture-data .capture-data-detail .capture-data-container .mat-icon{height:60px;width:60px;min-width:60px;min-height:60px}.capture-data .capture-data-detail .capture-data-name{font-size:10px}.cdk-drag-preview{box-sizing:border-box;border-radius:4px;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.example-list.cdk-drop-list-dragging .example-box:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}.mat-card{box-shadow:none!important;background:#FFFFFF;border:.5px solid #DCDCDC;border-radius:4px;padding:1rem!important;margin-bottom:1rem;align-items:center!important;min-width:100%}.mat-card .data-detail-info .data-detail-title{margin:0!important}@media screen and (max-width: 768px){dynamic-data-view .data-detail-content{margin:0!important}dynamic-data-view .data-detail-content .mat-card{padding:.8rem!important}.mat-card{padding:.8rem!important}}\n"] }]
    }], function () { return []; }, { form: [{
            type: Input
        }], dataDetailView: [{
            type: Input
        }], baseUrl: [{
            type: Input
        }], axonatorX1Url: [{
            type: Input
        }], showHeader: [{
            type: Input
        }], ScreenType: [{
            type: Input
        }], taskDetailsMap: [{
            type: Input
        }], taskStatus: [{
            type: Input
        }], showGhostLoader: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 