import { __awaiter } from "tslib";
import { Component, ChangeDetectionStrategy, Inject } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
import { TITLED_DIALOG_DATA } from '@anglr/common/material';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/dialog";
import * as i2 from "../codeEditor/codeEditor.component";
import * as i3 from "@anglr/common";
/**
 * Component used as dialog displaying code editor
 */
export class CodeEditorDialogComponent {
    //######################### constructor #########################
    constructor(data, dialog) {
        this.data = data;
        this.dialog = dialog;
        //######################### protected properties - template bindings #########################
        /**
         * Current content of code editor
         */
        this.editorContent = null;
    }
    //######################### protected methods - template bindings #########################
    /**
     * Saves content of code editor and closes dialog
     * @param editor - Instance of code editor
     */
    saveAndClose(editor) {
        return __awaiter(this, void 0, void 0, function* () {
            yield editor.saveContent();
            this.dialog.close(this.editorContent);
        });
    }
}
CodeEditorDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CodeEditorDialogComponent, deps: [{ token: TITLED_DIALOG_DATA }, { token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
CodeEditorDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.4", type: CodeEditorDialogComponent, selector: "code-editor-dialog", ngImport: i0, template: "<code-editor #editor style=\"height: calc(70vh - 46px); width: calc(75vw - 20px);\" [content]=\"data.content\" [languageModel]=\"data.languageModel\" (save)=\"editorContent = $event\"></code-editor>\n\n<div class=\"dynamic-flex-row dynamic-flex-end dynamic-action-buttons\">\n    <button type=\"button\" class=\"dynamic-btn dynamic-btn-info dynamic-margin-right-extra-small\" type=\"button\" [mat-dialog-close]=\"null\">\n        <span>{{'cancel'|firstUppercaseLocalize}}</span>\n    </button>\n\n    <button type=\"button\" class=\"dynamic-btn dynamic-btn-primary\" type=\"button\" (click)=\"saveAndClose(editor)\">\n        <span>{{'ok'|firstUppercaseLocalize}}</span>\n    </button>\n</div>", dependencies: [{ kind: "directive", type: i1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { kind: "component", type: i2.CodeEditorComponent, selector: "code-editor", inputs: ["content", "languageModel"], outputs: ["save", "contentChange"] }, { kind: "pipe", type: i3.FirstUppercaseLocalizeSAPipe, name: "firstUppercaseLocalize" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CodeEditorDialogComponent, decorators: [{
            type: Component,
            args: [{ selector: 'code-editor-dialog', changeDetection: ChangeDetectionStrategy.OnPush, template: "<code-editor #editor style=\"height: calc(70vh - 46px); width: calc(75vw - 20px);\" [content]=\"data.content\" [languageModel]=\"data.languageModel\" (save)=\"editorContent = $event\"></code-editor>\n\n<div class=\"dynamic-flex-row dynamic-flex-end dynamic-action-buttons\">\n    <button type=\"button\" class=\"dynamic-btn dynamic-btn-info dynamic-margin-right-extra-small\" type=\"button\" [mat-dialog-close]=\"null\">\n        <span>{{'cancel'|firstUppercaseLocalize}}</span>\n    </button>\n\n    <button type=\"button\" class=\"dynamic-btn dynamic-btn-primary\" type=\"button\" (click)=\"saveAndClose(editor)\">\n        <span>{{'ok'|firstUppercaseLocalize}}</span>\n    </button>\n</div>" }]
        }], ctorParameters: () => [{ type: undefined, decorators: [{
                    type: Inject,
                    args: [TITLED_DIALOG_DATA]
                }] }, { type: i1.MatDialogRef }] });
//# sourceMappingURL=codeEditorDialog.component.js.map