import * as i0 from '@angular/core';
import { Component, Inject, EventEmitter, 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 i2 from '@angular/material/dialog';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import * as i1 from '@angular/forms';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import * as i3 from '@angular/material/divider';
import { MatDividerModule } from '@angular/material/divider';
import * as i4 from '@angular/material/form-field';
import * as i5 from '@angular/material/select';
import { MatSelectModule } from '@angular/material/select';
import * as i6 from '@angular/material/core';
import * as i7 from '@angular/material/input';
import { MatInputModule } from '@angular/material/input';
import * as i8 from '@angular/material/tooltip';
import { MatTooltipModule } from '@angular/material/tooltip';
import * as i9 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i2$1 from '@asoftwareworld/qrcode';
import { AswQrCodeModule } from '@asoftwareworld/qrcode';
import * as i3$1 from '@angular/material/button';
import { MatButtonModule } from '@angular/material/button';
import * as i4$1 from '@angular/material/icon';
import { MatIconModule } from '@angular/material/icon';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';

/**
 * @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 AswQrCodeDialog {
    constructor(formBuilder, dialogRef, control) {
        this.formBuilder = formBuilder;
        this.dialogRef = dialogRef;
        this.control = control;
        this.constants = Constants;
    }
    ngOnInit() {
        this.validateFormBuilder();
        this.editProperty(this.control);
    }
    validateFormBuilder() {
        this.aswEditQrCodeForm = this.formBuilder.group({
            qrCodeSize: [''],
            centerImage: ['', []],
            centerImageSize: [''],
            errorCorrectionLevel: [''],
            value: [''],
            column: ['']
        });
    }
    editProperty(control) {
        this.aswEditQrCodeForm.setValue({
            qrCodeSize: control.qrCodeSize,
            centerImage: control.centerImage,
            centerImageSize: control.centerImageSize,
            errorCorrectionLevel: control.errorCorrectionLevel,
            value: control.value,
            column: control.column,
        });
    }
    onNoClick() {
        this.dialogRef.close();
    }
    onSubmit() {
        if (this.aswEditQrCodeForm.invalid) {
            return;
        }
        this.aswEditQrCodeForm.value.controlType = this.control.controlType;
        this.dialogRef.close(this.aswEditQrCodeForm.value);
    }
}
AswQrCodeDialog.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswQrCodeDialog, deps: [{ token: i1.FormBuilder }, { token: i2.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
AswQrCodeDialog.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: AswQrCodeDialog, selector: "asw-qrcode-dialog", ngImport: i0, template: "<h4 mat-dialog-title>Edit Property</h4>\r\n<mat-divider></mat-divider>\r\n<form [formGroup]=\"aswEditQrCodeForm\" (ngSubmit)=\"onSubmit()\">\r\n    <mat-dialog-content class=\"mat-typography\">\r\n        <div class=\"asw-full-width\"><br>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Center Image</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"centerImage\"\r\n                                        placeholder=\"Enter center image\"\r\n                                        matTooltip=\"Enter center image\"\r\n                                        formControlName=\"centerImage\">\r\n                    </mat-form-field>\r\n                </div>\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Center Image Size</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"centerImageSize\"\r\n                                        placeholder=\"Enter center image size\"\r\n                                        matTooltip=\"Enter center image size\"\r\n                                        formControlName=\"centerImageSize\">\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-12\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Error Correction Level</mat-label>\r\n                        <mat-select formControlName=\"errorCorrectionLevel\" matTooltip=\"Select error correction level\">\r\n                            <mat-option *ngFor=\"let value of constants.errorCorrectionLevels\"\r\n                                [value]=\"value\">\r\n                                {{value}}\r\n                            </mat-option>\r\n                        </mat-select>\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Value</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"value\"\r\n                                        placeholder=\"Enter value\"\r\n                                        matTooltip=\"Enter value\"\r\n                                        formControlName=\"value\">                        \r\n                    </mat-form-field>\r\n                </div>\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>QR Code Size</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"qrCodeSize\"\r\n                                        placeholder=\"Enter QR Code Size\"\r\n                                        matTooltip=\"Enter QR Code Size\"\r\n                                        formControlName=\"qrCodeSize\">\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-12\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Column Size</mat-label>\r\n                        <mat-select formControlName=\"column\" matTooltip=\"Select column size\">\r\n                            <mat-option *ngFor=\"let column of constants.columns\" [value]=\"column.value\">\r\n                                {{column.label}}\r\n                            </mat-option>\r\n                        </mat-select>\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </mat-dialog-content>\r\n    <mat-dialog-actions align=\"end\">\r\n        <button type=\"button\"\r\n                class=\"btn btn-danger mr-2 me-2 mb-1\"\r\n                (click)=\"onNoClick()\">\r\n            No\r\n        </button>\r\n        <button type=\"submit\"\r\n                class=\"btn btn-primary mb-1\"\r\n                cdkFocusInitial>\r\n            Yes\r\n        </button>\r\n    </mat-dialog-actions>\r\n</form>\r\n\r\n", components: [{ type: i3.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { type: i4.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i5.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i6.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i4.MatLabel, selector: "mat-label" }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl],      input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i8.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i9.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswQrCodeDialog, decorators: [{
            type: Component,
            args: [{ selector: 'asw-qrcode-dialog', template: "<h4 mat-dialog-title>Edit Property</h4>\r\n<mat-divider></mat-divider>\r\n<form [formGroup]=\"aswEditQrCodeForm\" (ngSubmit)=\"onSubmit()\">\r\n    <mat-dialog-content class=\"mat-typography\">\r\n        <div class=\"asw-full-width\"><br>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Center Image</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"centerImage\"\r\n                                        placeholder=\"Enter center image\"\r\n                                        matTooltip=\"Enter center image\"\r\n                                        formControlName=\"centerImage\">\r\n                    </mat-form-field>\r\n                </div>\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Center Image Size</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"centerImageSize\"\r\n                                        placeholder=\"Enter center image size\"\r\n                                        matTooltip=\"Enter center image size\"\r\n                                        formControlName=\"centerImageSize\">\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-12\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Error Correction Level</mat-label>\r\n                        <mat-select formControlName=\"errorCorrectionLevel\" matTooltip=\"Select error correction level\">\r\n                            <mat-option *ngFor=\"let value of constants.errorCorrectionLevels\"\r\n                                [value]=\"value\">\r\n                                {{value}}\r\n                            </mat-option>\r\n                        </mat-select>\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Value</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"value\"\r\n                                        placeholder=\"Enter value\"\r\n                                        matTooltip=\"Enter value\"\r\n                                        formControlName=\"value\">                        \r\n                    </mat-form-field>\r\n                </div>\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>QR Code Size</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"qrCodeSize\"\r\n                                        placeholder=\"Enter QR Code Size\"\r\n                                        matTooltip=\"Enter QR Code Size\"\r\n                                        formControlName=\"qrCodeSize\">\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-12\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Column Size</mat-label>\r\n                        <mat-select formControlName=\"column\" matTooltip=\"Select column size\">\r\n                            <mat-option *ngFor=\"let column of constants.columns\" [value]=\"column.value\">\r\n                                {{column.label}}\r\n                            </mat-option>\r\n                        </mat-select>\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </mat-dialog-content>\r\n    <mat-dialog-actions align=\"end\">\r\n        <button type=\"button\"\r\n                class=\"btn btn-danger mr-2 me-2 mb-1\"\r\n                (click)=\"onNoClick()\">\r\n            No\r\n        </button>\r\n        <button type=\"submit\"\r\n                class=\"btn btn-primary mb-1\"\r\n                cdkFocusInitial>\r\n            Yes\r\n        </button>\r\n    </mat-dialog-actions>\r\n</form>\r\n\r\n" }]
        }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: i2.MatDialogRef }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [MAT_DIALOG_DATA]
                }] }]; } });

/**
 * @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 AswQrCode {
    constructor(dialog) {
        this.dialog = dialog;
        this.constants = Constants;
        /**
         * QR Code control
         */
        this.control = null;
        this.isPreviewTemplate = false;
        this.qrCodeUpdateEvent = new EventEmitter();
        this.qrCodeDeleteEvent = new EventEmitter();
        this.duplicateControl = new EventEmitter();
    }
    deleteQrCodeDialog(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.qrCodeDeleteEvent.emit(controlIndex);
            }
        });
    }
    editQrCodeDialog(control, controlIndex) {
        const dialogRef = this.dialog.open(AswQrCodeDialog, {
            disableClose: true,
            width: '744px',
            data: control
        });
        dialogRef.afterClosed().subscribe(result => {
            if (result !== undefined) {
                this.qrCodeUpdateEvent.emit({ control: result, index: controlIndex });
            }
        });
    }
    duplicateQrCodeControl(control) {
        this.duplicateControl.emit(control);
    }
}
AswQrCode.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswQrCode, deps: [{ token: i2.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
AswQrCode.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: AswQrCode, selector: "asw-qrcode", inputs: { control: "control", controlIndex: "controlIndex", isPreviewTemplate: "isPreviewTemplate" }, outputs: { qrCodeUpdateEvent: "qrCodeUpdateEvent", qrCodeDeleteEvent: "qrCodeDeleteEvent", duplicateControl: "duplicateControl" }, ngImport: i0, template: "<ng-container *ngIf=\"control as control\">\r\n    <asw-qr-code [value]=\"control.value\" \r\n        [size]=\"control.qrCodeSize\"\r\n        [errorCorrectionLevel]=\"control.errorCorrectionLevel\"\r\n        [centerImageSrc]=\"control.centerImage\"\r\n        [centerImageSize]=\"control.centerImageSize\">\r\n    </asw-qr-code>\r\n    <ng-template [ngIf]=\"isPreviewTemplate\">\r\n        <div class=\"row mb-2\">\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)=\"duplicateQrCodeControl(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)=\"editQrCodeDialog(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)=\"deleteQrCodeDialog(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>", components: [{ type: i2$1.AswQrCodeComponent, selector: "asw-qr-code", inputs: ["value", "errorCorrectionLevel", "colorDark", "colorLight", "version", "size", "centerImageSrc", "centerImageSize"] }, { type: i3$1.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: i4$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i9.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswQrCode, decorators: [{
            type: Component,
            args: [{ selector: 'asw-qrcode', template: "<ng-container *ngIf=\"control as control\">\r\n    <asw-qr-code [value]=\"control.value\" \r\n        [size]=\"control.qrCodeSize\"\r\n        [errorCorrectionLevel]=\"control.errorCorrectionLevel\"\r\n        [centerImageSrc]=\"control.centerImage\"\r\n        [centerImageSize]=\"control.centerImageSize\">\r\n    </asw-qr-code>\r\n    <ng-template [ngIf]=\"isPreviewTemplate\">\r\n        <div class=\"row mb-2\">\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)=\"duplicateQrCodeControl(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)=\"editQrCodeDialog(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)=\"deleteQrCodeDialog(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>" }]
        }], ctorParameters: function () { return [{ type: i2.MatDialog }]; }, propDecorators: { control: [{
                type: Input
            }], controlIndex: [{
                type: Input
            }], isPreviewTemplate: [{
                type: Input
            }], qrCodeUpdateEvent: [{
                type: Output
            }], qrCodeDeleteEvent: [{
                type: Output
            }], duplicateControl: [{
                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
 */

/**
 * @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 QrCodeModule {
}
QrCodeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: QrCodeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
QrCodeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: QrCodeModule, declarations: [AswQrCode,
        AswQrCodeDialog], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule,
        MatInputModule,
        MatSelectModule,
        MatDialogModule,
        MatSlideToggleModule,
        MatTooltipModule,
        MatDividerModule,
        MatIconModule,
        AswConfirmDialogModule,
        AswQrCodeModule,
        MatButtonModule], exports: [AswQrCode,
        AswQrCodeDialog] });
QrCodeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: QrCodeModule, imports: [[
            CommonModule,
            FormsModule,
            ReactiveFormsModule,
            MatInputModule,
            MatSelectModule,
            MatDialogModule,
            MatSlideToggleModule,
            MatTooltipModule,
            MatDividerModule,
            MatIconModule,
            AswConfirmDialogModule,
            AswQrCodeModule,
            MatButtonModule
        ]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: QrCodeModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        CommonModule,
                        FormsModule,
                        ReactiveFormsModule,
                        MatInputModule,
                        MatSelectModule,
                        MatDialogModule,
                        MatSlideToggleModule,
                        MatTooltipModule,
                        MatDividerModule,
                        MatIconModule,
                        AswConfirmDialogModule,
                        AswQrCodeModule,
                        MatButtonModule
                    ],
                    declarations: [
                        AswQrCode,
                        AswQrCodeDialog
                    ],
                    exports: [
                        AswQrCode,
                        AswQrCodeDialog
                    ]
                }]
        }] });

/**
 * @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 { AswQrCode, AswQrCodeDialog, QrCodeModule };
//# sourceMappingURL=asoftwareworld-form-builder-form-control-qrcode.mjs.map
