/**
 * @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 { AswGpsDialog } from './gps-dialog';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/dialog";
import * as i2 from "@angular/material/form-field";
import * as i3 from "@angular/material/input";
import * as i4 from "@angular/forms";
import * as i5 from "@angular/material/tooltip";
import * as i6 from "@angular/common";
export class AswGps {
    constructor(dialog) {
        this.dialog = dialog;
        this.constants = Constants;
        this.isPreviewTemplate = false;
        this.gpsUpdateEvent = new EventEmitter();
        this.gpsDeleteEvent = new EventEmitter();
    }
    /**
     * Delete gps control based on control index
     * @param control gps control items
     * @param controlIndex gps control index
     */
    deleteGpsDialog(control, controlIndex) {
        const dialogRef = this.dialog.open(AswConfirmDialog, {
            width: '350px',
            data: { name: control.label, message: this.constants.messages.waringMessage }
        });
        dialogRef.afterClosed().subscribe(result => {
            if (result !== undefined) {
                this.gpsDeleteEvent.emit(controlIndex);
            }
        });
    }
    editGpsDialog(control, controlIndex) {
        const dialogRef = this.dialog.open(AswGpsDialog, {
            disableClose: true,
            width: '744px',
            data: control
        });
        dialogRef.afterClosed().subscribe(result => {
            if (result !== undefined) {
                this.gpsUpdateEvent.emit({ control: result, index: controlIndex });
            }
        });
    }
}
AswGps.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: AswGps, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
AswGps.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.2", type: AswGps, selector: "asw-gps", inputs: { control: "control", controlIndex: "controlIndex", isPreviewTemplate: "isPreviewTemplate" }, outputs: { gpsUpdateEvent: "gpsUpdateEvent", gpsDeleteEvent: "gpsDeleteEvent" }, ngImport: i0, template: "<mat-form-field appearance=\"outline\">\r\n    <mat-label>GPS</mat-label>\r\n    <input matInput type=\"text\"\r\n                    name=\"gps\"\r\n                    placeholder=\"Enter location\"\r\n                    [(ngModel)]=\"control.value\"\r\n                    ngModel\r\n                    #input\r\n                    matTooltip=\"Enter location\"\r\n                    [required]=\"control.isRequired\">               \r\n</mat-form-field>\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=\"Edit gps control\" \r\n                [matTooltipPosition]=\"'above'\" \r\n                (click)=\"editGpsDialog(control, controlIndex)\"\r\n                class=\"btn btn-sm btn-just-icon btn-outline-success mr-2 mb-1\">\r\n            <i class=\"material-icons\">edit</i>\r\n        </button>\r\n        <button mat-raised-button \r\n                type=\"button\" \r\n                matTooltip=\"Remove gps control\" \r\n                [matTooltipPosition]=\"'above'\" \r\n                (click)=\"deleteGpsDialog(control, controlIndex)\"\r\n                class=\"btn btn-sm btn-just-icon btn-outline-danger mb-1\">\r\n            <i class=\"material-icons\">close</i>\r\n        </button>\r\n    </div>                                            \r\n</div>", components: [{ type: i2.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }], directives: [{ type: i2.MatLabel, selector: "mat-label" }, { type: i3.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: i4.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: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i5.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i4.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: AswGps, decorators: [{
            type: Component,
            args: [{ selector: 'asw-gps', template: "<mat-form-field appearance=\"outline\">\r\n    <mat-label>GPS</mat-label>\r\n    <input matInput type=\"text\"\r\n                    name=\"gps\"\r\n                    placeholder=\"Enter location\"\r\n                    [(ngModel)]=\"control.value\"\r\n                    ngModel\r\n                    #input\r\n                    matTooltip=\"Enter location\"\r\n                    [required]=\"control.isRequired\">               \r\n</mat-form-field>\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=\"Edit gps control\" \r\n                [matTooltipPosition]=\"'above'\" \r\n                (click)=\"editGpsDialog(control, controlIndex)\"\r\n                class=\"btn btn-sm btn-just-icon btn-outline-success mr-2 mb-1\">\r\n            <i class=\"material-icons\">edit</i>\r\n        </button>\r\n        <button mat-raised-button \r\n                type=\"button\" \r\n                matTooltip=\"Remove gps control\" \r\n                [matTooltipPosition]=\"'above'\" \r\n                (click)=\"deleteGpsDialog(control, controlIndex)\"\r\n                class=\"btn btn-sm btn-just-icon btn-outline-danger mb-1\">\r\n            <i class=\"material-icons\">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
            }], gpsUpdateEvent: [{
                type: Output
            }], gpsDeleteEvent: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 