import { __decorate, __metadata } from "tslib";
import { Component, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef, Injector, Inject, Optional, Input } from '@angular/core';
import { MAT_TAB, MatTab, MatTabsModule } from '@angular/material/tabs';
import { CommonModule } from '@angular/common';
import { LayoutComponentBase, LayoutComponentRendererSADirective } from '@anglr/dynamic/layout';
import { DescendantsGetter, LayoutEditorMetadata } from '@anglr/dynamic/layout-editor';
import { RelationsEditorMetadata } from '@anglr/dynamic/relations-editor';
import { HostDisplayBlockStyle } from '@anglr/common';
import { MaterialTabLayoutMetadataLoader, MaterialTabRelationsMetadataLoader } from './tab.metadata';
import { MATERIAL_TAB_GROUP } from '../tabGroup/tabGroup.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/material/tabs";
/**
 * Component used for displaying toggle panel layout
 */
let MaterialTabSAComponent = class MaterialTabSAComponent extends LayoutComponentBase {
    //######################### public properties - inputs #########################
    /**
     * Indication whether tab is visible
     */
    set visible(visible) {
        this._visible = visible;
        if (this.visible) {
            this.showTab();
        }
        else {
            this.hideTab();
        }
    }
    get visible() {
        return this._visible;
    }
    //######################### constructor #########################
    constructor(changeDetector, componentElement, injector, _closestTabGroup, _closestTab) {
        super(changeDetector, componentElement, injector);
        this._closestTabGroup = _closestTabGroup;
        this._closestTab = _closestTab;
    }
    //######################### protected - overrides #########################
    /**
     * @inheritdoc
     */
    onOptionsSet() { }
    /**
     * Hides tab content
     */
    hideTab() {
        if (this._closestTab) {
            this._closestTab.disabled = true;
        }
        this._closestTabGroup?.onHideTab(this.tabGroupIndex);
    }
    /**
     * Shows tab content
     */
    showTab() {
        if (this._closestTab) {
            this._closestTab.disabled = false;
        }
        this._closestTabGroup?.invalidateVisuals();
    }
};
MaterialTabSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: MaterialTabSAComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.Injector }, { token: MATERIAL_TAB_GROUP, optional: true }, { token: MAT_TAB, optional: true }], target: i0.ɵɵFactoryTarget.Component });
MaterialTabSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.4", type: MaterialTabSAComponent, isStandalone: true, selector: "material-tab", inputs: { visible: "visible" }, usesInheritance: true, ngImport: i0, template: "<ng-container *ngFor=\"let type of options?.children\">\n    <ng-template [layoutComponentRenderer]=\"type\"></ng-template>\n</ng-container>", styles: [":host{display: block;}"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "ngmodule", type: MatTabsModule }, { kind: "directive", type: LayoutComponentRendererSADirective, selector: "[layoutComponentRenderer]", inputs: ["layoutComponentRenderer", "layoutComponentRendererInjector", "layoutComponentRendererDisableTransformer"], outputs: ["layoutComponentRendererComponentChange", "componentElementChange"], exportAs: ["layoutComponentRenderer"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
MaterialTabSAComponent = __decorate([
    DescendantsGetter(options => options?.children ?? []),
    LayoutEditorMetadata(MaterialTabLayoutMetadataLoader),
    RelationsEditorMetadata(MaterialTabRelationsMetadataLoader),
    __metadata("design:paramtypes", [ChangeDetectorRef,
        ElementRef,
        Injector, Object, MatTab])
], MaterialTabSAComponent);
export { MaterialTabSAComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: MaterialTabSAComponent, decorators: [{
            type: Component,
            args: [{ selector: 'material-tab', standalone: true, imports: [
                        CommonModule,
                        MatTabsModule,
                        LayoutComponentRendererSADirective,
                    ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngFor=\"let type of options?.children\">\n    <ng-template [layoutComponentRenderer]=\"type\"></ng-template>\n</ng-container>", styles: [":host{display: block;}"] }]
        }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.Injector }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [MATERIAL_TAB_GROUP]
                }, {
                    type: Optional
                }] }, { type: i2.MatTab, decorators: [{
                    type: Inject,
                    args: [MAT_TAB]
                }, {
                    type: Optional
                }] }], propDecorators: { visible: [{
                type: Input
            }] } });
//# sourceMappingURL=tab.component.js.map