/**
 * @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
 */
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { AswConfirmDialog } from '@asoftwareworld/form-builder/form-control/confirm-dialog';
import { Constants } from '@asoftwareworld/form-builder/form-control/core';
import { AswParagraphDialog } from './paragraph-dialog';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/dialog";
import * as i2 from "@angular/material/button";
import * as i3 from "@angular/material/icon";
import * as i4 from "@angular/common";
import * as i5 from "@angular/material/tooltip";
export class AswParagraph {
    constructor(dialog) {
        this.dialog = dialog;
        this.constants = Constants;
        /**
         * Paragraph control
         */
        this.control = null;
        this.isPreviewTemplate = false;
        this.paragraphUpdateEvent = new EventEmitter();
        this.paragraphDeleteEvent = new EventEmitter();
        this.duplicateControl = new EventEmitter();
    }
    deleteParagraphDialog(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.paragraphDeleteEvent.emit(controlIndex);
            }
        });
    }
    editParagraphDialog(control, controlIndex) {
        const dialogRef = this.dialog.open(AswParagraphDialog, {
            disableClose: true,
            width: '744px',
            data: control
        });
        dialogRef.afterClosed().subscribe(result => {
            if (result !== undefined) {
                this.paragraphUpdateEvent.emit({ control: result, index: controlIndex });
            }
        });
    }
    duplicateParagraphControl(control) {
        this.duplicateControl.emit(control);
    }
}
AswParagraph.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswParagraph, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
AswParagraph.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: AswParagraph, selector: "asw-paragraph", inputs: { control: "control", controlIndex: "controlIndex", isPreviewTemplate: "isPreviewTemplate" }, outputs: { paragraphUpdateEvent: "paragraphUpdateEvent", paragraphDeleteEvent: "paragraphDeleteEvent", duplicateControl: "duplicateControl" }, ngImport: i0, template: "<ng-container *ngIf=\"control as control\">\r\n    <ng-container [ngSwitch]=\"control.subtype\">\r\n        <ng-container *ngSwitchCase=\"'p'\">\r\n            <p class=\"{{control.style}} {{control.customClass}}\">\r\n                {{control.label}}\r\n            </p>\r\n        </ng-container>\r\n        <ng-container *ngSwitchCase=\"'address'\">\r\n            <address class=\"{{control.style}} {{control.customClass}}\">\r\n                {{control.label}}\r\n            </address>\r\n        </ng-container>\r\n        <ng-container *ngSwitchCase=\"'blockquote'\">\r\n            <blockquote class=\"{{control.style}} {{control.customClass}}\">\r\n                {{control.label}}\r\n            </blockquote>\r\n        </ng-container>\r\n        <ng-container *ngSwitchCase=\"'canvas'\">\r\n            <canvas class=\"{{control.style}} {{control.customClass}}\">\r\n                {{control.label}}\r\n            </canvas>\r\n        </ng-container>\r\n        <ng-container *ngSwitchCase=\"'output'\">\r\n            <output class=\"{{control.style}} {{control.customClass}}\">\r\n                {{control.label}}\r\n            </output>\r\n        </ng-container>\r\n    </ng-container>\r\n    <ng-template [ngIf]=\"isPreviewTemplate\">\r\n        <div class=\"row\">\r\n            <div class=\"col-md-12\">\r\n                <button mat-icon-button \r\n                        type=\"button\" \r\n                        matTooltip=\"Duplicate\" \r\n                        [matTooltipPosition]=\"'below'\" \r\n                        (click)=\"duplicateParagraphControl(control)\">\r\n                    <mat-icon>content_copy</mat-icon>\r\n                </button>\r\n                <button mat-icon-button \r\n                        type=\"button\" \r\n                        matTooltip=\"Edit\" \r\n                        [matTooltipPosition]=\"'below'\" \r\n                        (click)=\"editParagraphDialog(control, controlIndex)\">\r\n                    <mat-icon>edit</mat-icon>\r\n                </button>\r\n                <button mat-icon-button \r\n                        type=\"button\" \r\n                        matTooltip=\"Delete\" \r\n                        [matTooltipPosition]=\"'below'\" \r\n                        (click)=\"deleteParagraphDialog(control, controlIndex)\">\r\n                    <mat-icon>delete</mat-icon>\r\n                </button>\r\n            </div>                                            \r\n        </div>\r\n    </ng-template>    \r\n</ng-container>\r\n", components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button],             button[mat-fab], button[mat-mini-fab], button[mat-stroked-button],             button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i4.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i5.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswParagraph, decorators: [{
            type: Component,
            args: [{ selector: 'asw-paragraph', template: "<ng-container *ngIf=\"control as control\">\r\n    <ng-container [ngSwitch]=\"control.subtype\">\r\n        <ng-container *ngSwitchCase=\"'p'\">\r\n            <p class=\"{{control.style}} {{control.customClass}}\">\r\n                {{control.label}}\r\n            </p>\r\n        </ng-container>\r\n        <ng-container *ngSwitchCase=\"'address'\">\r\n            <address class=\"{{control.style}} {{control.customClass}}\">\r\n                {{control.label}}\r\n            </address>\r\n        </ng-container>\r\n        <ng-container *ngSwitchCase=\"'blockquote'\">\r\n            <blockquote class=\"{{control.style}} {{control.customClass}}\">\r\n                {{control.label}}\r\n            </blockquote>\r\n        </ng-container>\r\n        <ng-container *ngSwitchCase=\"'canvas'\">\r\n            <canvas class=\"{{control.style}} {{control.customClass}}\">\r\n                {{control.label}}\r\n            </canvas>\r\n        </ng-container>\r\n        <ng-container *ngSwitchCase=\"'output'\">\r\n            <output class=\"{{control.style}} {{control.customClass}}\">\r\n                {{control.label}}\r\n            </output>\r\n        </ng-container>\r\n    </ng-container>\r\n    <ng-template [ngIf]=\"isPreviewTemplate\">\r\n        <div class=\"row\">\r\n            <div class=\"col-md-12\">\r\n                <button mat-icon-button \r\n                        type=\"button\" \r\n                        matTooltip=\"Duplicate\" \r\n                        [matTooltipPosition]=\"'below'\" \r\n                        (click)=\"duplicateParagraphControl(control)\">\r\n                    <mat-icon>content_copy</mat-icon>\r\n                </button>\r\n                <button mat-icon-button \r\n                        type=\"button\" \r\n                        matTooltip=\"Edit\" \r\n                        [matTooltipPosition]=\"'below'\" \r\n                        (click)=\"editParagraphDialog(control, controlIndex)\">\r\n                    <mat-icon>edit</mat-icon>\r\n                </button>\r\n                <button mat-icon-button \r\n                        type=\"button\" \r\n                        matTooltip=\"Delete\" \r\n                        [matTooltipPosition]=\"'below'\" \r\n                        (click)=\"deleteParagraphDialog(control, controlIndex)\">\r\n                    <mat-icon>delete</mat-icon>\r\n                </button>\r\n            </div>                                            \r\n        </div>\r\n    </ng-template>    \r\n</ng-container>\r\n" }]
        }], ctorParameters: function () { return [{ type: i1.MatDialog }]; }, propDecorators: { control: [{
                type: Input
            }], controlIndex: [{
                type: Input
            }], isPreviewTemplate: [{
                type: Input
            }], paragraphUpdateEvent: [{
                type: Output
            }], paragraphDeleteEvent: [{
                type: Output
            }], duplicateControl: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 