import { Component, EventEmitter, Input, Output, ViewEncapsulation } from "@angular/core";
import { Subject } from "rxjs";
import { takeUntil } from "rxjs/operators";
import { DocumentNodeType } from "../common/document-folder-type.enum";
import { DataType } from "../../../common/enum/data-type.enum";
import * as i0 from "@angular/core";
import * as i1 from "@angular/platform-browser";
import * as i2 from "../../../services/translation-registry.service";
import * as i3 from "@angular/material/icon";
import * as i4 from "../../app-icon/icon-registry.service";
import * as i5 from "@angular/common";
import * as i6 from "../../button/button";
import * as i7 from "../../list/list";
import * as i8 from "../../breadcrumb/breadcrumb";
export class RelatedListComponent {
    constructor(domSanitizer, translate, iconRegistry, appIconService) {
        this.domSanitizer = domSanitizer;
        this.translate = translate;
        this.iconRegistry = iconRegistry;
        this.appIconService = appIconService;
        this.relatedData = [];
        this.dataType = DataType;
        // imageProcess = '../qms-angular/src/assets/images/union.svg';
        this.imageProcess = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTkiIHZpZXdCb3g9IjAgMCAxOCAxOSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMCAwLjVWNi41SDJWMTYuNUgxMlYxOC41SDE4VjEyLjVIMTJWMTQuNUg0VjYuNUg2VjQuNUgxMlY2LjVIMThWMC41SDEyVjIuNUg2VjAuNUgwWk00IDIuNVY0LjVIMlYyLjVINFpNMTYgMi41VjQuNUgxNFYyLjVIMTZaTTE2IDE2LjVWMTQuNUgxNFYxNi41SDE2WiIgZmlsbD0iYmxhY2siIGZpbGwtb3BhY2l0eT0iMC42Ii8+DQo8L3N2Zz4NCg==';
        this.updateData = new EventEmitter();
        this.onItemSelect = new EventEmitter();
        this.ngUnsubscribe = new Subject();
        appIconService.registerProcessIcon(iconRegistry, domSanitizer);
        appIconService.registerProcessAreaIcon(iconRegistry, domSanitizer);
        appIconService.registerDocumentIcon(iconRegistry, domSanitizer);
        appIconService.registerFolderIcon(iconRegistry, domSanitizer);
        appIconService.registerDeviationIcon(iconRegistry, domSanitizer);
        appIconService.registerChecklistIcon(iconRegistry, domSanitizer);
        appIconService.registerRiskIcon(iconRegistry, domSanitizer);
        appIconService.registerProcessInterconnectedIcon(iconRegistry, domSanitizer);
        appIconService.registerComplianceIcon(iconRegistry, domSanitizer);
        appIconService.registerLinkIcon(iconRegistry, domSanitizer);
    }
    ngOnChanges(changes) {
        if (changes.data && JSON.stringify(changes.data.currentValue) !== JSON.stringify(changes.data.previousValue)) {
            this.relatedData = [];
            this.title = changes.data.currentValue.title;
            this.isNotEditedItem = changes.data.currentValue['isNotEditedItem'] ?? false;
            this.relatedData = [...changes.data.currentValue.data];
        }
    }
    ngOnInit() {
        this.title = this.data.title;
        this.isNotEditedItem = this.data['isNotEditedItem'] ?? false;
        this.relatedData = this.data.data;
        this.translate.getLanguageSubject$.pipe(takeUntil(this.ngUnsubscribe)).subscribe((res) => {
            if (res) {
                this.LANG = this.translate.getObjectLang(res);
            }
        });
    }
    ngOnDestroy() {
        this.ngUnsubscribe.next();
        this.ngUnsubscribe.complete();
    }
    getImagePath() {
        return this.domSanitizer.bypassSecurityTrustResourceUrl(this.imageProcess);
    }
    removeItem(index) {
        this.updateData.emit(index);
    }
    onCloseClick() {
    }
    onItemClick(item) {
        if (this.onItemSelect)
            this.onItemSelect.emit(item);
    }
    onItemBreadcrumbClick(event) {
        if (this.onItemSelect)
            this.onItemSelect.emit(event);
    }
    getItemStatus(item) {
        return (this.showStatus && item?.statusName) ? `, ${item?.statusName}` : '';
    }
    getNodeIcon(item) {
        switch (item.itemType) {
            case DataType.folder: {
                switch (item.levelType) {
                    case DocumentNodeType.DepartmentFolder:
                        return 'department_folder_outlined';
                    case DocumentNodeType.RegionalFolder:
                        return 'regional_folder_outlined';
                    case DocumentNodeType.TopFolder:
                        return 'enterprise_folder_outlined';
                    case DocumentNodeType.Folder:
                        return 'local_folder_outlined';
                    default:
                        return 'folder_outlined';
                }
            }
            case DataType.document: {
                switch (item.levelType) {
                    case DocumentNodeType.DepartmentFolder:
                        return 'document_department';
                    case DocumentNodeType.RegionalFolder:
                        return 'document_regional';
                    case DocumentNodeType.TopFolder:
                        return 'document_enterprise';
                    case DocumentNodeType.Folder:
                        return 'document_local';
                    default:
                        return 'document';
                }
            }
            case DataType.area:
                return 'process_area_outlined';
            case DataType.process:
                return 'process';
            case DataType.deviation:
                return 'deviation';
            case DataType.checklist:
                return 'checklist';
            case DataType.risk:
                return 'risk';
            case DataType.processInterconnected:
                return 'process_interconnected';
            case DataType.compliance:
                return 'compliance';
            case DataType.link:
                return 'link';
            default:
                return 'folder_outlined';
        }
    }
    canShowParent(item) {
        return item.itemType === this.dataType.deviation || item.itemType === this.dataType.checklist;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: RelatedListComponent, deps: [{ token: i1.DomSanitizer }, { token: i2.TranslateLibraryService }, { token: i3.MatIconRegistry }, { token: i4.QMSIconRegistryService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: RelatedListComponent, selector: "qms-related-list", inputs: { data: "data", showStatus: "showStatus" }, outputs: { updateData: "updateData", onItemSelect: "onItemSelect" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"container list-related\">\n  <div class=\"list-related__title\">\n    <strong>{{ title }}</strong>\n  </div>\n  <div class=\"list-related__body\" *ngFor=\"let item of relatedData; let i = index\">\n    <div class=\"list-related__body-parent\">\n      <qms-list-item type=\"image-square\">\n        <mat-icon *ngIf=\"!item.svgIcon\" type=\"image-square\" leading-icon [svgIcon]=\"getNodeIcon(item)\"></mat-icon>\n        <mat-icon *ngIf=\"item.svgIcon\" type=\"image-square\" leading-icon>\n          <img class=\"unset-vertical-align\" [src]=\"item.svgIcon\" />\n        </mat-icon>\n        <div qms-list-header>\n          <div qms-line (click)=\"onItemClick(item)\" type=\"caption\" *ngIf=\"canShowParent(item)\">\n            {{ item?.parentName }}\n          </div>\n          <div qms-line (click)=\"onItemClick(item)\" type=\"subtitle\">\n            {{ item.itemName }}\n          </div>\n        </div>\n        <div qms-line *ngIf=\"item.breadcumbs && item.breadcumbs.length\">\n          <qms-breadcrumb class=\"breadcrumb-container\" type=\"table\" numDisplayItem=\"1\" [nodes]=\"item.breadcumbs\">\n          </qms-breadcrumb>\n        </div>\n        <div qms-line color=\"default-subtitle\" *ngIf=\"item?.displayId\">\n          <ng-container *ngIf=\"item?.displayId\">\n            <span>\n              <mat-icon class=\"material-icons-outlined\"> local_offer </mat-icon>\n            </span>\n            &nbsp;ID:\n            {{ item?.displayId }}\n          </ng-container>\n          <ng-container *ngIf=\"item.statusName\">\n            {{ getItemStatus(item) }}\n          </ng-container>\n        </div>\n        <button qms-btn-icon color=\"light\" mode=\"dark\"\n          *ngIf=\"!isNotEditedItem && (item.canRemove === undefined || item.canRemove)\" (click)=\"removeItem(i)\">\n          <mat-icon>close</mat-icon>\n        </button>\n      </qms-list-item>\n    </div>\n  </div>\n</div>", styles: [".list-related{font-family:Open Sans;font-style:normal;font-weight:400;color:var(--default-color)}.list-related .list-related__title{font-weight:600;font-size:.875rem;line-height:22px;margin-bottom:1rem}.list-related .list-related__body .list-related__body-parent{min-height:48px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #ddd}.list-related .list-related__body .list-related__body-parent .qms-list-item{height:unset!important}.list-related .list-related__body .list-related__body-parent .qms-list-item.mat-2-line.image-item{height:auto}.list-related .list-related__body .list-related__body-parent .qms-list-item.image-item .qms-list-item-content{margin:0}.list-related .list-related__body .list-related__body-parent .wrap-image.image-square,.list-related .list-related__body .list-related__body-parent .wrap-image.image-square img{background:transparent;margin:auto;height:24px;width:24px}.list-related .list-related__body .list-related__body-parent .qms-list-item.image-item .qms-list-text,.list-related .list-related__body .list-related__body-parent .qms-list-item.image-item .trailing-box{margin-left:1.5rem;border-bottom:none;padding-bottom:7px;padding-top:7px}.list-related .list-related__body .list-related__body-parent .qms-list-item.image-item .qms-list-text .material-icons-outlined,.list-related .list-related__body .list-related__body-parent .qms-list-item.image-item .trailing-box .material-icons-outlined{font-size:13px;height:13px;width:13px}.list-related .list-related__body .list-related__body-parent .block{font-weight:400;font-size:1rem;line-height:28px;display:flex;align-items:center}.list-related .list-related__body .list-related__body-parent .block .title{margin-left:1.5rem;padding-top:5px;padding-bottom:5px}.list-related .list-related__body .list-related__body-parent .block .title .caption{color:#0009;font-size:.75rem;line-height:22px}.list-related .list-related__body .list-related__body-parent .block mat-icon{color:#0009;padding:0}.list-related .list-related__body .list-related__body-parent .block button.qms-btn-icon{width:40px;height:40px;line-height:40px}.list-related .list-related__body .list-related__body-child{font-weight:400;font-size:.875rem;line-height:22px}.list-related .list-related__body .list-related__body-child .default{min-height:48px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #ddd}.list-related .list-related__body .list-related__body-child .default .title{margin-left:3rem}.list-related .list-related__body .list-related__body-child .default .group-button{margin-right:2rem;display:flex}.list-related .list-related__body .remain{font-weight:600;font-size:.875rem;line-height:22px;display:flex;align-items:center;justify-content:space-between;background-color:#fafafa;color:var(--primary);min-height:48px;border-bottom:1px solid #ddd}.list-related .list-related__body .remain .title{margin-left:3rem}.list-related .list-related__body .qms-line{display:flex;align-items:center}.list-related .list-related__body .breadcrumb-container .qms-breadcrumb-item{cursor:inherit;line-height:16px;font-size:.75rem;color:#0009;font-weight:400;line-height:22px;margin:0}.list-related .list-related__body .trailing-box{display:flex;align-items:center}.list-related .list-related__body .trailing-box button{height:24px;width:24px;line-height:24px}.list-related .unset-vertical-align{vertical-align:unset}.label-red,.label-yellow,.label-green{font-family:Open Sans;font-style:normal;font-weight:600;display:inline-block;text-align:center;margin-left:1rem;width:24px;height:24px;font-size:.75rem;border-radius:1px}.label-red{background-color:var(--secondary);color:#fff}.label-yellow{background-color:var(--risk-yellow);color:#000000de}.label-green{background-color:var(--risk-green);color:#fff}.cursor{cursor:pointer}\n"], dependencies: [{ kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i6.QMSButtonIcon, selector: "button[qms-btn-icon]", inputs: ["disabled", "color", "active"], exportAs: ["qmsButtonIcon"] }, { kind: "component", type: i7.QMSListItem, selector: "qms-list-item", inputs: ["type", "disabled"] }, { kind: "directive", type: i7.QMSListLeadingIcon, selector: "[leading-icon]" }, { kind: "directive", type: i7.QMSListLine, selector: "[qms-line]", inputs: ["size", "type", "color"] }, { kind: "directive", type: i7.QMSListHeader, selector: "[qms-list-header]" }, { kind: "component", type: i8.QMSBreadcrumb, selector: "qms-breadcrumb", inputs: ["nodes", "type", "maxLine", "numDisplayItem", "onlyItem", "disabledLastItem"], outputs: ["onItemClick"] }], encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: RelatedListComponent, decorators: [{
            type: Component,
            args: [{ selector: 'qms-related-list', encapsulation: ViewEncapsulation.None, template: "<div class=\"container list-related\">\n  <div class=\"list-related__title\">\n    <strong>{{ title }}</strong>\n  </div>\n  <div class=\"list-related__body\" *ngFor=\"let item of relatedData; let i = index\">\n    <div class=\"list-related__body-parent\">\n      <qms-list-item type=\"image-square\">\n        <mat-icon *ngIf=\"!item.svgIcon\" type=\"image-square\" leading-icon [svgIcon]=\"getNodeIcon(item)\"></mat-icon>\n        <mat-icon *ngIf=\"item.svgIcon\" type=\"image-square\" leading-icon>\n          <img class=\"unset-vertical-align\" [src]=\"item.svgIcon\" />\n        </mat-icon>\n        <div qms-list-header>\n          <div qms-line (click)=\"onItemClick(item)\" type=\"caption\" *ngIf=\"canShowParent(item)\">\n            {{ item?.parentName }}\n          </div>\n          <div qms-line (click)=\"onItemClick(item)\" type=\"subtitle\">\n            {{ item.itemName }}\n          </div>\n        </div>\n        <div qms-line *ngIf=\"item.breadcumbs && item.breadcumbs.length\">\n          <qms-breadcrumb class=\"breadcrumb-container\" type=\"table\" numDisplayItem=\"1\" [nodes]=\"item.breadcumbs\">\n          </qms-breadcrumb>\n        </div>\n        <div qms-line color=\"default-subtitle\" *ngIf=\"item?.displayId\">\n          <ng-container *ngIf=\"item?.displayId\">\n            <span>\n              <mat-icon class=\"material-icons-outlined\"> local_offer </mat-icon>\n            </span>\n            &nbsp;ID:\n            {{ item?.displayId }}\n          </ng-container>\n          <ng-container *ngIf=\"item.statusName\">\n            {{ getItemStatus(item) }}\n          </ng-container>\n        </div>\n        <button qms-btn-icon color=\"light\" mode=\"dark\"\n          *ngIf=\"!isNotEditedItem && (item.canRemove === undefined || item.canRemove)\" (click)=\"removeItem(i)\">\n          <mat-icon>close</mat-icon>\n        </button>\n      </qms-list-item>\n    </div>\n  </div>\n</div>", styles: [".list-related{font-family:Open Sans;font-style:normal;font-weight:400;color:var(--default-color)}.list-related .list-related__title{font-weight:600;font-size:.875rem;line-height:22px;margin-bottom:1rem}.list-related .list-related__body .list-related__body-parent{min-height:48px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #ddd}.list-related .list-related__body .list-related__body-parent .qms-list-item{height:unset!important}.list-related .list-related__body .list-related__body-parent .qms-list-item.mat-2-line.image-item{height:auto}.list-related .list-related__body .list-related__body-parent .qms-list-item.image-item .qms-list-item-content{margin:0}.list-related .list-related__body .list-related__body-parent .wrap-image.image-square,.list-related .list-related__body .list-related__body-parent .wrap-image.image-square img{background:transparent;margin:auto;height:24px;width:24px}.list-related .list-related__body .list-related__body-parent .qms-list-item.image-item .qms-list-text,.list-related .list-related__body .list-related__body-parent .qms-list-item.image-item .trailing-box{margin-left:1.5rem;border-bottom:none;padding-bottom:7px;padding-top:7px}.list-related .list-related__body .list-related__body-parent .qms-list-item.image-item .qms-list-text .material-icons-outlined,.list-related .list-related__body .list-related__body-parent .qms-list-item.image-item .trailing-box .material-icons-outlined{font-size:13px;height:13px;width:13px}.list-related .list-related__body .list-related__body-parent .block{font-weight:400;font-size:1rem;line-height:28px;display:flex;align-items:center}.list-related .list-related__body .list-related__body-parent .block .title{margin-left:1.5rem;padding-top:5px;padding-bottom:5px}.list-related .list-related__body .list-related__body-parent .block .title .caption{color:#0009;font-size:.75rem;line-height:22px}.list-related .list-related__body .list-related__body-parent .block mat-icon{color:#0009;padding:0}.list-related .list-related__body .list-related__body-parent .block button.qms-btn-icon{width:40px;height:40px;line-height:40px}.list-related .list-related__body .list-related__body-child{font-weight:400;font-size:.875rem;line-height:22px}.list-related .list-related__body .list-related__body-child .default{min-height:48px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #ddd}.list-related .list-related__body .list-related__body-child .default .title{margin-left:3rem}.list-related .list-related__body .list-related__body-child .default .group-button{margin-right:2rem;display:flex}.list-related .list-related__body .remain{font-weight:600;font-size:.875rem;line-height:22px;display:flex;align-items:center;justify-content:space-between;background-color:#fafafa;color:var(--primary);min-height:48px;border-bottom:1px solid #ddd}.list-related .list-related__body .remain .title{margin-left:3rem}.list-related .list-related__body .qms-line{display:flex;align-items:center}.list-related .list-related__body .breadcrumb-container .qms-breadcrumb-item{cursor:inherit;line-height:16px;font-size:.75rem;color:#0009;font-weight:400;line-height:22px;margin:0}.list-related .list-related__body .trailing-box{display:flex;align-items:center}.list-related .list-related__body .trailing-box button{height:24px;width:24px;line-height:24px}.list-related .unset-vertical-align{vertical-align:unset}.label-red,.label-yellow,.label-green{font-family:Open Sans;font-style:normal;font-weight:600;display:inline-block;text-align:center;margin-left:1rem;width:24px;height:24px;font-size:.75rem;border-radius:1px}.label-red{background-color:var(--secondary);color:#fff}.label-yellow{background-color:var(--risk-yellow);color:#000000de}.label-green{background-color:var(--risk-green);color:#fff}.cursor{cursor:pointer}\n"] }]
        }], ctorParameters: () => [{ type: i1.DomSanitizer }, { type: i2.TranslateLibraryService }, { type: i3.MatIconRegistry }, { type: i4.QMSIconRegistryService }], propDecorators: { data: [{
                type: Input
            }], showStatus: [{
                type: Input
            }], updateData: [{
                type: Output
            }], onItemSelect: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 