import { Component, Input } from '@angular/core';
import { cloneDeep } from 'lodash-es';
import { UUID } from 'angular2-uuid';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "primeng/tabview";
import * as i3 from "primeng/api";
import * as i4 from "../smz-tables/features/table/table.component";
import * as i5 from "../../common/pipes/safe-html.pipe";
export class SmzMultiTablesComponent {
    constructor() { }
    ngOnInit() { }
    duplicate(tab) {
        const copy = cloneDeep(tab);
        const id = UUID.UUID();
        copy._isDuplicated = true;
        copy.allowDuplication = false;
        copy.closable = true;
        copy._id = id;
        const count = this.state.tabs
            .filter(s => s._originalId === tab._id)
            .length;
        copy.header.label.name += ` (${count + 1})`;
        this.state.tabs.push(copy);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: SmzMultiTablesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.5", type: SmzMultiTablesComponent, selector: "smz-ui-multi-tables", inputs: { state: "state" }, ngImport: i0, template: `
<ng-container *ngIf="state != null">

<p-tabView [styleClass]="state.styleClass">

<ng-container *ngFor="let tab of state.tabs">
    <p-tabPanel [ngClass]="tab.styleClass" [selected]="tab.selected" [closable]="tab.closable">
        <ng-template pTemplate="header">
            <i *ngIf="tab.header.icon.isVisible" class="{{ tab.header.icon.name }} mr-2" [ngClass]="tab.header.icon.styleClass"></i>
            <span [innerHTML]="tab.header.label.name | safeHtml"></span>
            <i *ngIf="tab.allowDuplication" class="fa-solid fa-clone cursor-pointer ml-2" (click)="duplicate(tab)"></i>
        </ng-template>
        <smz-ui-table *ngIf="tab.table != null" [items]="tab.table.items$ | async" [state]="tab.table.state"></smz-ui-table>
    </p-tabPanel>
</ng-container>

</p-tabView>

</ng-container>
  `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.TabView, selector: "p-tabView", inputs: ["style", "styleClass", "controlClose", "scrollable", "activeIndex", "selectOnFocus", "nextButtonAriaLabel", "prevButtonAriaLabel", "autoHideButtons", "tabindex"], outputs: ["onChange", "onClose", "activeIndexChange"] }, { kind: "component", type: i2.TabPanel, selector: "p-tabPanel", inputs: ["closable", "headerStyle", "headerStyleClass", "cache", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "selected", "disabled", "header", "leftIcon", "rightIcon"] }, { kind: "directive", type: i3.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "component", type: i4.SmzTableComponent, selector: "smz-ui-table", inputs: ["state", "items", "loading"], outputs: ["selectionChange", "filterChange", "columnVisibilityChange", "create", "update", "delete"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.SafeHtmlPipe, name: "safeHtml" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: SmzMultiTablesComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'smz-ui-multi-tables',
                    template: `
<ng-container *ngIf="state != null">

<p-tabView [styleClass]="state.styleClass">

<ng-container *ngFor="let tab of state.tabs">
    <p-tabPanel [ngClass]="tab.styleClass" [selected]="tab.selected" [closable]="tab.closable">
        <ng-template pTemplate="header">
            <i *ngIf="tab.header.icon.isVisible" class="{{ tab.header.icon.name }} mr-2" [ngClass]="tab.header.icon.styleClass"></i>
            <span [innerHTML]="tab.header.label.name | safeHtml"></span>
            <i *ngIf="tab.allowDuplication" class="fa-solid fa-clone cursor-pointer ml-2" (click)="duplicate(tab)"></i>
        </ng-template>
        <smz-ui-table *ngIf="tab.table != null" [items]="tab.table.items$ | async" [state]="tab.table.state"></smz-ui-table>
    </p-tabPanel>
</ng-container>

</p-tabView>

</ng-container>
  `
                }]
        }], ctorParameters: () => [], propDecorators: { state: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibXVsdGktdGFibGVzLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL25neC1zbXotdWkvc3JjL2xpYi9tb2R1bGVzL3Ntei1tdWx0aS10YWJsZXMvbXVsdGktdGFibGVzLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLEtBQUssRUFBVSxNQUFNLGVBQWUsQ0FBQztBQUV6RCxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBQ3RDLE9BQU8sRUFBRSxJQUFJLEVBQUUsTUFBTSxlQUFlLENBQUM7Ozs7Ozs7QUEwQnJDLE1BQU0sT0FBTyx1QkFBdUI7SUFFbEMsZ0JBQWdCLENBQUM7SUFFakIsUUFBUSxLQUFLLENBQUM7SUFFUCxTQUFTLENBQUMsR0FBc0I7UUFFckMsTUFBTSxJQUFJLEdBQUcsU0FBUyxDQUFDLEdBQUcsQ0FBQyxDQUFDO1FBRTVCLE1BQU0sRUFBRSxHQUFHLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUV2QixJQUFJLENBQUMsYUFBYSxHQUFHLElBQUksQ0FBQztRQUMxQixJQUFJLENBQUMsZ0JBQWdCLEdBQUcsS0FBSyxDQUFDO1FBQzlCLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDO1FBQ3JCLElBQUksQ0FBQyxHQUFHLEdBQUcsRUFBRSxDQUFDO1FBRWQsTUFBTSxLQUFLLEdBQUcsSUFBSSxDQUFDLEtBQUssQ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