import * as i0 from '@angular/core';
import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
import { AswConfirmDialog, AswConfirmDialogModule } from '@asoftwareworld/form-builder/form-control/confirm-dialog';
import { Constants } from '@asoftwareworld/form-builder/form-control/core';
import * as i1 from '@angular/material/dialog';
import { MatDialogModule } from '@angular/material/dialog';
import * as i2 from '@angular/material/divider';
import { MatDividerModule } from '@angular/material/divider';
import * as i3 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i4 from '@angular/material/tooltip';
import { MatTooltipModule } from '@angular/material/tooltip';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

/**
 * @license
 * Copyright ASW (A Software World) All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file
 */
class AswDivider {
    constructor(dialog) {
        this.dialog = dialog;
        this.constants = Constants;
        this.isPreviewTemplate = false;
        this.dividerDeleteEvent = new EventEmitter();
    }
    /**
     * Delete divider control based on control index
     * @param control divider control items
     * @param controlIndex divider control index
     */
    deleteHeaderDialog(control, controlIndex) {
        const dialogRef = this.dialog.open(AswConfirmDialog, {
            width: '350px',
            data: { name: control.controlType, message: this.constants.messages.waringMessage }
        });
        dialogRef.afterClosed().subscribe(result => {
            if (result !== undefined) {
                this.dividerDeleteEvent.emit(controlIndex);
            }
        });
    }
}
AswDivider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswDivider, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
AswDivider.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: AswDivider, selector: "asw-divider", inputs: { control: "control", controlIndex: "controlIndex", isPreviewTemplate: "isPreviewTemplate" }, outputs: { dividerDeleteEvent: "dividerDeleteEvent" }, ngImport: i0, template: "<mat-divider></mat-divider>\r\n<div class=\"row\" *ngIf=\"isPreviewTemplate\">\r\n    <div class=\"col-md-12\">        \r\n        <button mat-raised-button \r\n                type=\"button\" \r\n                matTooltip=\"Remove divider control\" \r\n                [matTooltipPosition]=\"'above'\" \r\n                (click)=\"deleteHeaderDialog(control, controlIndex)\"\r\n                class=\"asw-btn btn btn-sm btn-just-icon btn-outline-danger mb-1\">\r\n            <i class=\"material-icons asw-material-icon\">close</i>\r\n        </button>\r\n    </div>                                            \r\n</div>", components: [{ type: i2.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswDivider, decorators: [{
            type: Component,
            args: [{ selector: 'asw-divider', template: "<mat-divider></mat-divider>\r\n<div class=\"row\" *ngIf=\"isPreviewTemplate\">\r\n    <div class=\"col-md-12\">        \r\n        <button mat-raised-button \r\n                type=\"button\" \r\n                matTooltip=\"Remove divider control\" \r\n                [matTooltipPosition]=\"'above'\" \r\n                (click)=\"deleteHeaderDialog(control, controlIndex)\"\r\n                class=\"asw-btn btn btn-sm btn-just-icon btn-outline-danger mb-1\">\r\n            <i class=\"material-icons asw-material-icon\">close</i>\r\n        </button>\r\n    </div>                                            \r\n</div>" }]
        }], ctorParameters: function () { return [{ type: i1.MatDialog }]; }, propDecorators: { control: [{
                type: Input
            }], controlIndex: [{
                type: Input
            }], isPreviewTemplate: [{
                type: Input
            }], dividerDeleteEvent: [{
                type: Output
            }] } });

/**
 * @license
 * Copyright ASW (A Software World) All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file
 */
class AswDividerModule {
}
AswDividerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswDividerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
AswDividerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswDividerModule, declarations: [AswDivider], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule,
        MatDividerModule,
        MatDialogModule,
        MatTooltipModule,
        AswConfirmDialogModule], exports: [AswDivider] });
AswDividerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswDividerModule, imports: [[
            CommonModule,
            FormsModule,
            ReactiveFormsModule,
            MatDividerModule,
            MatDialogModule,
            MatTooltipModule,
            AswConfirmDialogModule
        ]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswDividerModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        CommonModule,
                        FormsModule,
                        ReactiveFormsModule,
                        MatDividerModule,
                        MatDialogModule,
                        MatTooltipModule,
                        AswConfirmDialogModule
                    ],
                    declarations: [
                        AswDivider
                    ],
                    exports: [
                        AswDivider
                    ]
                }]
        }] });

/**
 * @license
 * Copyright ASW (A Software World) All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file
 */

/**
 * Generated bundle index. Do not edit.
 */

export { AswDivider, AswDividerModule };
//# sourceMappingURL=asoftwareworld-form-builder-form-control-divider.mjs.map
