import * as i0 from '@angular/core';
import { Component, Inject, ViewEncapsulation, ChangeDetectionStrategy, Input, ElementRef, EventEmitter, Output, HostBinding, ContentChild, forwardRef, Directive, Self, NgModule } from '@angular/core';
import * as i1 from '@angular/forms';
import { Validators, FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { takeUntil, startWith } from 'rxjs/operators';
import { Subject } from 'rxjs';
import QuillBetterTable from 'quill-better-table';
import * as i1$2 from '@eui/components-next';
import { DYNAMIC_COMPONENT_CONFIG, EuiDialogConfig, EuiMessageBoxConfig, EuiTooltipDirectiveModule, EuiMessageBoxModule, EuiDialogModule } from '@eui/components-next';
import * as i3 from '@eui/externals/quill';
import { QuillModule } from '@eui/externals/quill';
import * as i4 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i1$1 from '@angular/platform-browser';
import QuillType from 'quill';

const urlValidator = (control) => {
    const isHttp = control.value.substr(0, 7) === 'http://';
    const isHttps = control.value.substr(0, 8) === 'https://';
    return !isHttp && !isHttps ? { 'isUrlValid': false } : null;
};
class EuiEditorImageDialogComponent {
    constructor(config, fb) {
        this.config = config;
        this.fb = fb;
        this.destroy$ = new Subject();
    }
    ngOnInit() {
        this.form = this.fb.group({
            url: ['', [Validators.required, urlValidator]],
        });
        this.form.valueChanges.pipe(takeUntil(this.destroy$)).subscribe((value) => {
            this.config.onFormValueChange(this.form);
        });
    }
    ngOnDestroy() {
        this.destroy$.next(true);
        this.destroy$.unsubscribe();
    }
}
/** @nocollapse */ EuiEditorImageDialogComponent.ɵfac = function EuiEditorImageDialogComponent_Factory(t) { return new (t || EuiEditorImageDialogComponent)(i0.ɵɵdirectiveInject(DYNAMIC_COMPONENT_CONFIG), i0.ɵɵdirectiveInject(i1.FormBuilder)); };
/** @nocollapse */ EuiEditorImageDialogComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiEditorImageDialogComponent, selectors: [["ng-component"]], decls: 2, vars: 1, consts: [[3, "formGroup"], ["formControlName", "url", 1, "ux-form-control"]], template: function EuiEditorImageDialogComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelementStart(0, "form", 0);
        i0.ɵɵelement(1, "input", 1);
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵproperty("formGroup", ctx.form);
    } }, directives: [i1.ɵangular_packages_forms_forms_y, i1.NgControlStatusGroup, i1.FormGroupDirective, i1.DefaultValueAccessor, i1.NgControlStatus, i1.FormControlName], encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiEditorImageDialogComponent, [{
        type: Component,
        args: [{
                templateUrl: 'image-url-dialog.component.html',
            }]
    }], function () { return [{ type: undefined, decorators: [{
                type: Inject,
                args: [DYNAMIC_COMPONENT_CONFIG]
            }] }, { type: i1.FormBuilder }]; }, null); })();

function EuiEditorCountersComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2);
    i0.ɵɵelementStart(1, "span", 3);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "span", 4);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("chars-counter--error", !ctx_r0.isMaxLengthValid);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r0.charactersCounter);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r0.charactersLabel);
} }
function EuiEditorCountersComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2);
    i0.ɵɵelementStart(1, "span", 5);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "span", 6);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.wordsCounter);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.wordsLabel);
} }
class EuiEditorCountersComponent {
    constructor() {
        this.charactersLabel = 'characters';
        this.wordsLabel = 'words';
        this.isMaxLengthValid = true;
        this._hasCharactersCounter = true;
        this._hasWordsCounter = true;
    }
    get hasCharactersCounter() { return this._hasCharactersCounter; }
    set hasCharactersCounter(value) { this._hasCharactersCounter = coerceBooleanProperty(value); }
    get hasWordsCounter() { return this._hasWordsCounter; }
    set hasWordsCounter(value) { this._hasWordsCounter = coerceBooleanProperty(value); }
}
/** @nocollapse */ EuiEditorCountersComponent.ɵfac = function EuiEditorCountersComponent_Factory(t) { return new (t || EuiEditorCountersComponent)(); };
/** @nocollapse */ EuiEditorCountersComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiEditorCountersComponent, selectors: [["eui-editor-counters"]], inputs: { charactersCounter: "charactersCounter", charactersLabel: "charactersLabel", wordsCounter: "wordsCounter", wordsLabel: "wordsLabel", isMaxLengthValid: "isMaxLengthValid", hasCharactersCounter: "hasCharactersCounter", hasWordsCounter: "hasWordsCounter" }, decls: 3, vars: 2, consts: [[1, "editor-counters"], ["class", "flex-container flex-column ml-1 mr-1", 4, "ngIf"], [1, "flex-container", "flex-column", "ml-1", "mr-1"], [1, "chars-counter"], [1, "chars-label"], [1, "words-counter"], [1, "words-label"]], template: function EuiEditorCountersComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelementStart(0, "button", 0);
        i0.ɵɵtemplate(1, EuiEditorCountersComponent_div_1_Template, 5, 4, "div", 1);
        i0.ɵɵtemplate(2, EuiEditorCountersComponent_div_2_Template, 5, 2, "div", 1);
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.hasCharactersCounter);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.hasWordsCounter);
    } }, directives: [i4.NgIf], encapsulation: 2, changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiEditorCountersComponent, [{
        type: Component,
        args: [{
                // tslint:disable-next-line
                selector: 'eui-editor-counters',
                templateUrl: './eui-editor-counters.component.html',
                encapsulation: ViewEncapsulation.None,
                changeDetection: ChangeDetectionStrategy.OnPush,
            }]
    }], function () { return []; }, { charactersCounter: [{
            type: Input
        }], charactersLabel: [{
            type: Input
        }], wordsCounter: [{
            type: Input
        }], wordsLabel: [{
            type: Input
        }], isMaxLengthValid: [{
            type: Input
        }], hasCharactersCounter: [{
            type: Input
        }], hasWordsCounter: [{
            type: Input
        }] }); })();

class EuiEditorHtmlViewComponent {
    constructor(sanitizer) {
        this.sanitizer = sanitizer;
        this.content = '';
        this.theme = 'snow';
        this.innerHTML = '';
        this.themeClass = 'ql-snow';
    }
    ngOnChanges(changes) {
        if (changes && changes.content) {
            this.innerHTML = this.sanitizer.bypassSecurityTrustHtml(changes.content.currentValue);
        }
    }
}
/** @nocollapse */ EuiEditorHtmlViewComponent.ɵfac = function EuiEditorHtmlViewComponent_Factory(t) { return new (t || EuiEditorHtmlViewComponent)(i0.ɵɵdirectiveInject(i1$1.DomSanitizer)); };
/** @nocollapse */ EuiEditorHtmlViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiEditorHtmlViewComponent, selectors: [["eui-editor-html-view"]], inputs: { content: "content", theme: "theme" }, features: [i0.ɵɵNgOnChangesFeature], decls: 3, vars: 2, consts: [[1, "ql-container", 3, "ngClass"], ["editor", ""], [1, "ql-editor", 3, "innerHTML"]], template: function EuiEditorHtmlViewComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelementStart(0, "div", 0, 1);
        i0.ɵɵelement(2, "div", 2);
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵproperty("ngClass", ctx.themeClass);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("innerHTML", ctx.innerHTML, i0.ɵɵsanitizeHtml);
    } }, directives: [i4.NgClass], encapsulation: 2, changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiEditorHtmlViewComponent, [{
        type: Component,
        args: [{
                // tslint:disable-next-line
                selector: 'eui-editor-html-view',
                templateUrl: './eui-editor-html-view.component.html',
                encapsulation: ViewEncapsulation.None,
                changeDetection: ChangeDetectionStrategy.OnPush,
            }]
    }], function () { return [{ type: i1$1.DomSanitizer }]; }, { content: [{
            type: Input
        }], theme: [{
            type: Input
        }] }); })();

class EuiEditorJsonViewComponent {
    constructor(elementRef) {
        this.elementRef = elementRef;
        this.theme = 'snow';
        this.valueSetter = (quillEditor, value) => {
            let content = value;
            try {
                content = JSON.parse(value);
            }
            catch (e) {
                console.warn('JSON parse error!');
            }
            quillEditor.setContents(content);
        };
    }
    ngAfterViewInit() {
        this.elementRef.nativeElement.insertAdjacentHTML('afterbegin', '<div quill-view-element></div>');
        this.editorElem = this.elementRef.nativeElement.querySelector('[quill-view-element]');
        this.quillEditor = new QuillType(this.editorElem, {
            debug: false,
            formats: null,
            modules: { toolbar: false },
            readOnly: true,
            strict: true,
            theme: 'snow',
        });
        if (this.content) {
            this.valueSetter(this.quillEditor, this.content);
        }
    }
}
/** @nocollapse */ EuiEditorJsonViewComponent.ɵfac = function EuiEditorJsonViewComponent_Factory(t) { return new (t || EuiEditorJsonViewComponent)(i0.ɵɵdirectiveInject(ElementRef)); };
/** @nocollapse */ EuiEditorJsonViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiEditorJsonViewComponent, selectors: [["eui-editor-json-view"]], inputs: { theme: "theme", content: "content" }, decls: 0, vars: 0, template: function EuiEditorJsonViewComponent_Template(rf, ctx) { }, encapsulation: 2, changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiEditorJsonViewComponent, [{
        type: Component,
        args: [{
                // tslint:disable-next-line
                selector: 'eui-editor-json-view',
                template: '',
                encapsulation: ViewEncapsulation.None,
                changeDetection: ChangeDetectionStrategy.OnPush,
            }]
    }], function () { return [{ type: i0.ElementRef, decorators: [{
                type: Inject,
                args: [ElementRef]
            }] }]; }, { theme: [{
            type: Input
        }], content: [{
            type: Input
        }] }); })();

function EuiEditorComponent_div_2_span_1_option_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "option", 12);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const value_r16 = ctx.$implicit;
    i0.ɵɵpropertyInterpolate("value", value_r16);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1("Heading ", value_r16, "");
} }
function EuiEditorComponent_div_2_span_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelementStart(1, "select", 9);
    i0.ɵɵtemplate(2, EuiEditorComponent_div_2_span_1_option_2_Template, 2, 2, "option", 10);
    i0.ɵɵelementStart(3, "option", 11);
    i0.ɵɵtext(4, "Normal");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r4.toolbarConfig.headings.label);
    i0.ɵɵadvance(1);
    i0.ɵɵattribute("aria-label", ctx_r4.toolbarConfig.headings.label);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r4.toolbarConfig.headings.options);
} }
function EuiEditorComponent_div_2_span_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelementStart(1, "select", 13);
    i0.ɵɵelementStart(2, "option", 11);
    i0.ɵɵtext(3, "Sans Serif");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "option", 14);
    i0.ɵɵtext(5, "Serif");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "option", 15);
    i0.ɵɵtext(7, "Monospace");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r5.toolbarConfig.font.label);
    i0.ɵɵadvance(1);
    i0.ɵɵattribute("aria-label", ctx_r5.toolbarConfig.font.label);
} }
function EuiEditorComponent_div_2_span_3_button_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 21);
} if (rf & 2) {
    const ctx_r17 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r17.toolbarConfig.bold.label);
    i0.ɵɵattribute("aria-label", ctx_r17.toolbarConfig.bold.label);
} }
function EuiEditorComponent_div_2_span_3_button_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 22);
} if (rf & 2) {
    const ctx_r18 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r18.toolbarConfig.italic.label);
    i0.ɵɵattribute("aria-label", ctx_r18.toolbarConfig.italic.label);
} }
function EuiEditorComponent_div_2_span_3_button_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 23);
} if (rf & 2) {
    const ctx_r19 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r19.toolbarConfig.underline.label);
    i0.ɵɵattribute("aria-label", ctx_r19.toolbarConfig.underline.label);
} }
function EuiEditorComponent_div_2_span_3_button_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 24);
} if (rf & 2) {
    const ctx_r20 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r20.toolbarConfig.strike.label);
    i0.ɵɵattribute("aria-label", ctx_r20.toolbarConfig.strike.label);
} }
function EuiEditorComponent_div_2_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 16);
    i0.ɵɵtemplate(1, EuiEditorComponent_div_2_span_3_button_1_Template, 1, 2, "button", 17);
    i0.ɵɵtemplate(2, EuiEditorComponent_div_2_span_3_button_2_Template, 1, 2, "button", 18);
    i0.ɵɵtemplate(3, EuiEditorComponent_div_2_span_3_button_3_Template, 1, 2, "button", 19);
    i0.ɵɵtemplate(4, EuiEditorComponent_div_2_span_3_button_4_Template, 1, 2, "button", 20);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r6.toolbarConfig.bold);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r6.toolbarConfig.italic);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r6.toolbarConfig.underline);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r6.toolbarConfig.strike);
} }
function EuiEditorComponent_div_2_span_4_span_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 26);
    i0.ɵɵelement(1, "select", 27);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r21 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r21.toolbarConfig.fontColor.label);
    i0.ɵɵadvance(1);
    i0.ɵɵattribute("aria-label", ctx_r21.toolbarConfig.fontColor.label);
} }
function EuiEditorComponent_div_2_span_4_span_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 26);
    i0.ɵɵelement(1, "select", 28);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r22 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r22.toolbarConfig.fontBackground.label);
    i0.ɵɵadvance(1);
    i0.ɵɵattribute("aria-label", ctx_r22.toolbarConfig.fontBackground.label);
} }
function EuiEditorComponent_div_2_span_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 16);
    i0.ɵɵtemplate(1, EuiEditorComponent_div_2_span_4_span_1_Template, 2, 2, "span", 25);
    i0.ɵɵtemplate(2, EuiEditorComponent_div_2_span_4_span_2_Template, 2, 2, "span", 25);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r7 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r7.toolbarConfig.fontColor);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r7.toolbarConfig.fontBackground);
} }
function EuiEditorComponent_div_2_span_5_button_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 31);
} if (rf & 2) {
    const ctx_r23 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r23.toolbarConfig.subscript.label);
    i0.ɵɵattribute("aria-label", ctx_r23.toolbarConfig.subscript.label);
} }
function EuiEditorComponent_div_2_span_5_button_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 32);
} if (rf & 2) {
    const ctx_r24 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r24.toolbarConfig.superscript.label);
    i0.ɵɵattribute("aria-label", ctx_r24.toolbarConfig.superscript.label);
} }
function EuiEditorComponent_div_2_span_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 16);
    i0.ɵɵtemplate(1, EuiEditorComponent_div_2_span_5_button_1_Template, 1, 2, "button", 29);
    i0.ɵɵtemplate(2, EuiEditorComponent_div_2_span_5_button_2_Template, 1, 2, "button", 30);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r8 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.toolbarConfig.subscript);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.toolbarConfig.superscript);
} }
function EuiEditorComponent_div_2_span_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 16);
    i0.ɵɵelementStart(1, "span", 26);
    i0.ɵɵelementStart(2, "select", 33);
    i0.ɵɵelement(3, "option", 11);
    i0.ɵɵelement(4, "option", 34);
    i0.ɵɵelement(5, "option", 35);
    i0.ɵɵelement(6, "option", 36);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r9 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r9.toolbarConfig.textAlign.label);
    i0.ɵɵadvance(1);
    i0.ɵɵattribute("aria-label", ctx_r9.toolbarConfig.textAlign.label);
} }
function EuiEditorComponent_div_2_span_7_button_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 41);
} if (rf & 2) {
    const ctx_r25 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r25.toolbarConfig.orderedList.label);
    i0.ɵɵattribute("aria-label", ctx_r25.toolbarConfig.orderedList.label);
} }
function EuiEditorComponent_div_2_span_7_button_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 42);
} if (rf & 2) {
    const ctx_r26 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r26.toolbarConfig.bulletList.label);
    i0.ɵɵattribute("aria-label", ctx_r26.toolbarConfig.bulletList.label);
} }
function EuiEditorComponent_div_2_span_7_button_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 43);
} if (rf & 2) {
    const ctx_r27 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r27.toolbarConfig.indentLess.label);
    i0.ɵɵattribute("aria-label", ctx_r27.toolbarConfig.indentLess.label);
} }
function EuiEditorComponent_div_2_span_7_button_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 44);
} if (rf & 2) {
    const ctx_r28 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r28.toolbarConfig.indentMore.label);
    i0.ɵɵattribute("aria-label", ctx_r28.toolbarConfig.indentMore.label);
} }
function EuiEditorComponent_div_2_span_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 16);
    i0.ɵɵtemplate(1, EuiEditorComponent_div_2_span_7_button_1_Template, 1, 2, "button", 37);
    i0.ɵɵtemplate(2, EuiEditorComponent_div_2_span_7_button_2_Template, 1, 2, "button", 38);
    i0.ɵɵtemplate(3, EuiEditorComponent_div_2_span_7_button_3_Template, 1, 2, "button", 39);
    i0.ɵɵtemplate(4, EuiEditorComponent_div_2_span_7_button_4_Template, 1, 2, "button", 40);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r10 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r10.toolbarConfig.orderedList);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r10.toolbarConfig.bulletList);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r10.toolbarConfig.indentLess);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r10.toolbarConfig.indentMore);
} }
function EuiEditorComponent_div_2_span_8_button_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 51);
} if (rf & 2) {
    const ctx_r29 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r29.toolbarConfig.blockquote.label);
    i0.ɵɵattribute("aria-label", ctx_r29.toolbarConfig.blockquote.label);
} }
function EuiEditorComponent_div_2_span_8_button_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 52);
} if (rf & 2) {
    const ctx_r30 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r30.toolbarConfig.codeBlock.label);
    i0.ɵɵattribute("aria-label", ctx_r30.toolbarConfig.codeBlock.label);
} }
function EuiEditorComponent_div_2_span_8_button_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 53);
} if (rf & 2) {
    const ctx_r31 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r31.toolbarConfig.link.label);
    i0.ɵɵattribute("aria-label", ctx_r31.toolbarConfig.link.label);
} }
function EuiEditorComponent_div_2_span_8_button_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 54);
} if (rf & 2) {
    const ctx_r32 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r32.toolbarConfig.image.label);
    i0.ɵɵattribute("aria-label", ctx_r32.toolbarConfig.image.label);
} }
function EuiEditorComponent_div_2_span_8_button_5_Template(rf, ctx) { if (rf & 1) {
    const _r37 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 55);
    i0.ɵɵlistener("click", function EuiEditorComponent_div_2_span_8_button_5_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r37); const ctx_r36 = i0.ɵɵnextContext(3); return ctx_r36.imageUrlHandler(); });
    i0.ɵɵelement(1, "span", 56);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r33 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r33.toolbarConfig.imageUrl.label);
    i0.ɵɵattribute("aria-label", ctx_r33.toolbarConfig.imageUrl.label);
} }
function EuiEditorComponent_div_2_span_8_button_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 57);
} if (rf & 2) {
    const ctx_r34 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r34.toolbarConfig.video.label);
    i0.ɵɵattribute("aria-label", ctx_r34.toolbarConfig.video.label);
} }
function EuiEditorComponent_div_2_span_8_button_7_Template(rf, ctx) { if (rf & 1) {
    const _r39 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 55);
    i0.ɵɵlistener("click", function EuiEditorComponent_div_2_span_8_button_7_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r39); const ctx_r38 = i0.ɵɵnextContext(3); return ctx_r38.insertTable(); });
    i0.ɵɵelement(1, "span", 58);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r35 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r35.toolbarConfig.table.label);
    i0.ɵɵattribute("aria-label", ctx_r35.toolbarConfig.table.label);
} }
function EuiEditorComponent_div_2_span_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 16);
    i0.ɵɵtemplate(1, EuiEditorComponent_div_2_span_8_button_1_Template, 1, 2, "button", 45);
    i0.ɵɵtemplate(2, EuiEditorComponent_div_2_span_8_button_2_Template, 1, 2, "button", 46);
    i0.ɵɵtemplate(3, EuiEditorComponent_div_2_span_8_button_3_Template, 1, 2, "button", 47);
    i0.ɵɵtemplate(4, EuiEditorComponent_div_2_span_8_button_4_Template, 1, 2, "button", 48);
    i0.ɵɵtemplate(5, EuiEditorComponent_div_2_span_8_button_5_Template, 2, 2, "button", 49);
    i0.ɵɵtemplate(6, EuiEditorComponent_div_2_span_8_button_6_Template, 1, 2, "button", 50);
    i0.ɵɵtemplate(7, EuiEditorComponent_div_2_span_8_button_7_Template, 2, 2, "button", 49);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r11 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r11.toolbarConfig.blockquote);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r11.toolbarConfig.codeBlock);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r11.toolbarConfig.link);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r11.toolbarConfig.image);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r11.toolbarConfig.imageUrl);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r11.toolbarConfig.video);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r11.toolbarConfig.table);
} }
function EuiEditorComponent_div_2_span_9_button_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "button", 60);
} if (rf & 2) {
    const ctx_r40 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r40.toolbarConfig.clean.label);
    i0.ɵɵattribute("aria-label", ctx_r40.toolbarConfig.clean.label);
} }
function EuiEditorComponent_div_2_span_9_button_2_Template(rf, ctx) { if (rf & 1) {
    const _r43 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 55);
    i0.ɵɵlistener("click", function EuiEditorComponent_div_2_span_9_button_2_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r43); const ctx_r42 = i0.ɵɵnextContext(3); return ctx_r42.editorDeleteContent(); });
    i0.ɵɵelement(1, "span", 61);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r41 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r41.toolbarConfig.delete.label);
    i0.ɵɵattribute("aria-label", ctx_r41.toolbarConfig.delete.label);
} }
function EuiEditorComponent_div_2_span_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 16);
    i0.ɵɵtemplate(1, EuiEditorComponent_div_2_span_9_button_1_Template, 1, 2, "button", 59);
    i0.ɵɵtemplate(2, EuiEditorComponent_div_2_span_9_button_2_Template, 2, 2, "button", 49);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r12 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r12.toolbarConfig.clean);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r12.toolbarConfig.delete);
} }
function EuiEditorComponent_div_2_span_10_button_1_Template(rf, ctx) { if (rf & 1) {
    const _r47 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 55);
    i0.ɵɵlistener("click", function EuiEditorComponent_div_2_span_10_button_1_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r47); const ctx_r46 = i0.ɵɵnextContext(3); return ctx_r46.editorUndo(); });
    i0.ɵɵelement(1, "span", 62);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r44 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r44.toolbarConfig.undo.label);
    i0.ɵɵattribute("aria-label", ctx_r44.toolbarConfig.undo.label);
} }
function EuiEditorComponent_div_2_span_10_button_2_Template(rf, ctx) { if (rf & 1) {
    const _r49 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 55);
    i0.ɵɵlistener("click", function EuiEditorComponent_div_2_span_10_button_2_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r49); const ctx_r48 = i0.ɵɵnextContext(3); return ctx_r48.editorRedo(); });
    i0.ɵɵelement(1, "span", 63);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r45 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r45.toolbarConfig.redo.label);
    i0.ɵɵattribute("aria-label", ctx_r45.toolbarConfig.redo.label);
} }
function EuiEditorComponent_div_2_span_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 16);
    i0.ɵɵtemplate(1, EuiEditorComponent_div_2_span_10_button_1_Template, 2, 2, "button", 49);
    i0.ɵɵtemplate(2, EuiEditorComponent_div_2_span_10_button_2_Template, 2, 2, "button", 49);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r13 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r13.toolbarConfig.undo);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r13.toolbarConfig.redo);
} }
function EuiEditorComponent_div_2_span_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 16);
    i0.ɵɵelement(1, "eui-editor-counters", 64);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r14 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵpropertyInterpolate("euiTooltip", ctx_r14.toolbarConfig.counters.label);
    i0.ɵɵproperty("hasCharactersCounter", ctx_r14.hasCharactersCounter)("charactersCounter", ctx_r14.charactersCount)("charactersLabel", ctx_r14.charactersCounterLabel)("hasWordsCounter", ctx_r14.hasWordsCounter)("wordsCounter", ctx_r14.wordsCount)("wordsLabel", ctx_r14.wordsCounterLabel);
    i0.ɵɵattribute("aria-label", ctx_r14.toolbarConfig.counters.label);
} }
function EuiEditorComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 5);
    i0.ɵɵtemplate(1, EuiEditorComponent_div_2_span_1_Template, 5, 3, "span", 6);
    i0.ɵɵtemplate(2, EuiEditorComponent_div_2_span_2_Template, 8, 2, "span", 6);
    i0.ɵɵtemplate(3, EuiEditorComponent_div_2_span_3_Template, 5, 4, "span", 7);
    i0.ɵɵtemplate(4, EuiEditorComponent_div_2_span_4_Template, 3, 2, "span", 7);
    i0.ɵɵtemplate(5, EuiEditorComponent_div_2_span_5_Template, 3, 2, "span", 7);
    i0.ɵɵtemplate(6, EuiEditorComponent_div_2_span_6_Template, 7, 2, "span", 7);
    i0.ɵɵtemplate(7, EuiEditorComponent_div_2_span_7_Template, 5, 4, "span", 7);
    i0.ɵɵtemplate(8, EuiEditorComponent_div_2_span_8_Template, 8, 7, "span", 7);
    i0.ɵɵtemplate(9, EuiEditorComponent_div_2_span_9_Template, 3, 2, "span", 7);
    i0.ɵɵtemplate(10, EuiEditorComponent_div_2_span_10_Template, 3, 2, "span", 7);
    i0.ɵɵtemplate(11, EuiEditorComponent_div_2_span_11_Template, 2, 8, "span", 7);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.headings);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.font);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.bold || ctx_r0.toolbarConfig.italic || ctx_r0.toolbarConfig.underline || ctx_r0.toolbarConfig.strike);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.fontColor || ctx_r0.toolbarConfig.fontBackground);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.subscript || ctx_r0.toolbarConfig.superscript);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.textAlign);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.orderedList || ctx_r0.toolbarConfig.bulletList || ctx_r0.toolbarConfig.indentLess || ctx_r0.toolbarConfig.indentMore);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.blockquote || ctx_r0.toolbarConfig.codeBlock || ctx_r0.toolbarConfig.link || ctx_r0.toolbarConfig.image || ctx_r0.toolbarConfig.imageUrl || ctx_r0.toolbarConfig.video || ctx_r0.toolbarConfig.table);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.clean || ctx_r0.toolbarConfig.delete);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.undo || ctx_r0.toolbarConfig.redo);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.toolbarConfig.counters);
} }
function EuiEditorComponent_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 5);
    i0.ɵɵprojection(1);
    i0.ɵɵelementEnd();
} }
function EuiEditorComponent_eui_editor_html_view_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "eui-editor-html-view", 65);
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵproperty("content", ctx_r2.value)("theme", ctx_r2.theme);
} }
function EuiEditorComponent_eui_editor_json_view_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "eui-editor-json-view", 65);
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵproperty("content", ctx_r3.jsonToHtmlContent)("theme", ctx_r3.theme);
} }
const _c0 = [[["euiEditorCustomToolbar"]]];
const _c1 = ["euiEditorCustomToolbar"];
class EuiEditorComponent {
    constructor(euiDialogService, euiMessageBoxService, ngControl) {
        this.euiDialogService = euiDialogService;
        this.euiMessageBoxService = euiMessageBoxService;
        this.ngControl = ngControl;
        this.e2eAttr = 'eui-editor';
        this.styleClass = '';
        this.placeholder = '';
        this.format = 'html';
        this.isReadOnly = false;
        this.theme = 'snow';
        this.debug = false;
        this.customToolbarPosition = 'top';
        this.tabindex = '0';
        this.showCounters = true;
        this._isEnabledOnFocus = false;
        this._isMinimalToolbar = false;
        // DEPRECATED INPUTS (Keep for backward compatibility) - These will be dropped with eUI13+
        this.style = null; // DEPRECATED
        this.isRequired = false; // DEPRECATED
        this.isEditable = false; // DEPRECATED
        this.feedbackTypeClass = 'danger'; // DEPRECATED
        this.hasReadOnlyStyles = false; // DEPRECATED
        this.strict = true; // DEPRECATED
        this.customOptions = []; // DEPRECATED
        this.preserveWhitespace = false; // DEPRECATED
        this.spellcheck = false; // DEPRECATED
        this.isImageUrl = false; // DEPRECATED
        // DEPRECATED OLD EMITTERS (Keep for backward compatibility) - These will be dropped with eUI13+
        this.onInit = new EventEmitter(); // DEPRECATED
        this.onTextChange = new EventEmitter(); // DEPRECATED
        this.onSelectionChange = new EventEmitter(); // DEPRECATED
        this.onEditorCreated = new EventEmitter(); // DEPRECATED
        this.onEditorChanged = new EventEmitter(); // DEPRECATED
        this.onContentChanged = new EventEmitter(); // DEPRECATED
        this.onSelectionChanged = new EventEmitter(); // DEPRECATED
        this.onFocus = new EventEmitter(); // DEPRECATED
        this.onBlur = new EventEmitter(); // DEPRECATED
        this.getCharactersCounter = new EventEmitter(); // DEPRECATED
        this.getWordsCounter = new EventEmitter(); // DEPRECATED
        // NEW OUTPUTS => eUI13+ only
        this.editorCreate = new EventEmitter();
        this.editorChange = new EventEmitter();
        this.contentChange = new EventEmitter();
        this.selectionChange = new EventEmitter();
        this.focus = new EventEmitter();
        this.blur = new EventEmitter();
        this.charactersCountChange = new EventEmitter();
        this.wordsCountChange = new EventEmitter();
        this._isInvalid = false;
        this.value = '';
        this.charactersCount = 0;
        this.wordsCount = 0;
        this.bytesCount = 0;
        this.isFocused = false;
        this.formControl = new FormControl();
        this.customModules = [{
                path: 'modules/better-table',
                implementation: QuillBetterTable
            }];
        this.minimalToolbarConfig = [
            { name: 'headings' },
            { name: 'bold' },
            { name: 'italic' },
            { name: 'underline' },
            { name: 'fontColor' },
            { name: 'textAlign' },
            { name: 'link' },
            { name: 'image' },
            { name: 'imageUrl' },
            { name: 'clean' },
            { name: 'delete' },
            { name: 'undo' },
            { name: 'redo' },
            { name: 'counters' },
        ];
        this.defaultToolbarConfig = [
            { name: 'headings', label: 'Style - Apply an HTML tag or CSS class to the selected text', options: [1, 2, 3, 4, 5, 6] },
            { name: 'font', label: 'Font - Change the font face' },
            { name: 'bold', label: 'Bold (Ctrl + B) - Make the selected text bold' },
            { name: 'italic', label: 'Italic (Ctrl + I) - Italicize the selected text' },
            { name: 'underline', label: 'Underline (Ctrl + U) - Underline the selected text' },
            { name: 'strike', label: 'Strikethrough - Draw a line to the middle of the selected text' },
            { name: 'fontColor', label: 'Font Color - Change the text color' },
            { name: 'fontBackground', label: 'Font Background - Change the text background color' },
            { name: 'subscript', label: 'Subscript - Create ssmall letters below the text baseline' },
            { name: 'superscript', label: 'Superscript - Create small letters above the line of the text' },
            { name: 'textAlign', label: 'Text Align - Align the text to the selected position: left (default), center, right or justify' },
            { name: 'orderedList', label: 'Numbering - Start an ordered list' },
            { name: 'bulletList', label: 'Bullets - Start a bulleted list' },
            { name: 'indentLess', label: 'Decrease Indent - Decrease the indent level of the paragraph' },
            { name: 'indentMore', label: 'Increase Indent - Increase the indent level of the paragraph' },
            { name: 'blockquote', label: 'Blockquote - Create a quoted block of the selected text' },
            { name: 'codeBlock', label: 'Insert Code Block - Insert a code block at the cursor row position' },
            { name: 'link', label: 'Insert Hyperlink (Ctrl + K) - Create a link to a Web page, a picture, an e-mail address or a program' },
            { name: 'image', label: 'Insert Picture - Insert a picture from a file' },
            { name: 'imageUrl', label: 'Insert Picture from URL - Insert a picture from a remote URL', dialogMessage: 'Enter image link URL' },
            { name: 'video', label: 'Insert Video - Insert a video from a file' },
            { name: 'table', label: 'Insert Table - Insert a 3x3 rows/cols table' },
            { name: 'clean', label: 'Remove Styles - Remove the styles of the selected text' },
            { name: 'delete', label: 'Delete content - Permanently deletes editor\'s contents' },
            { name: 'undo', label: 'Undo (Ctrl + Z) - Cancels the previous action' },
            { name: 'redo', label: 'Redo (Ctrl + Y) - Do the next history action again' },
            { name: 'counters', label: 'Counters - Characters and words counters (stripped Html)', options: [
                    { name: 'characters', label: 'Characters' },
                    { name: 'words', label: 'Words' },
                ] },
        ];
        this.destroy$ = new Subject();
        this.onChange = () => { };
        this.onTouch = () => { };
        this.ngControl.valueAccessor = this;
    }
    get isEnabledOnFocus() { return this._isEnabledOnFocus; }
    set isEnabledOnFocus(value) { this._isEnabledOnFocus = coerceBooleanProperty(value); }
    get isMinimalToolbar() { return this._isMinimalToolbar; }
    set isMinimalToolbar(value) { this._isMinimalToolbar = coerceBooleanProperty(value); }
    get readonly() {
        return this.isReadOnly ? 'readonly' : null;
    }
    get isInvalid() { return this._isInvalid; }
    set isInvalid(value) { this._isInvalid = value; }
    ngOnInit() {
        this.ngControl.statusChanges.pipe(startWith(this.ngControl.control.status), takeUntil(this.destroy$)).subscribe((status) => {
            this.isInvalid = status !== 'VALID';
        });
        this.generatedId = this.id ? this.id : 'eui-editor-' + (Math.floor(Math.random() * 1000000) + 1).toString();
        this.toolbarConfig = {};
        if (!this.customToolbarConfig && !this.isMinimalToolbar) {
            this.defaultToolbarConfig.forEach((t) => {
                this.toolbarConfig = Object.assign(Object.assign({}, this.toolbarConfig), { [t.name]: { label: t.label, options: t.options, dialogMessage: t.dialogMessage } });
            });
        }
        if (this.customToolbarConfig && !this.isMinimalToolbar) {
            this.customToolbarConfig.forEach((t) => {
                const label = !t.label ? this.defaultToolbarConfig.find(c => c.name === t.name).label : t.label;
                let options = !t.options ? this.defaultToolbarConfig.find(c => c.name === t.name).options : t.options;
                const d = !t.dialogMessage ? this.defaultToolbarConfig.find(c => c.name === t.name).dialogMessage : t.dialogMessage;
                if (t.name === 'counters') {
                    if (!t.options) {
                        options = this.defaultToolbarConfig.find(c => c.name === t.name).options;
                    }
                    else {
                        options = t.options.map((option) => {
                            const optionLabel = option.label ? option.label : this.defaultToolbarConfig
                                .find(dtc => dtc.name === 'counters').options
                                .find(o => o.name === option.name).label;
                            return { name: option.name, label: optionLabel };
                        });
                    }
                }
                this.toolbarConfig = Object.assign(Object.assign({}, this.toolbarConfig), { [t.name]: { label, options, dialogMessage: d } });
            });
        }
        if (this.isMinimalToolbar) {
            this.minimalToolbarConfig.forEach((t) => {
                const label = !t.label ? this.defaultToolbarConfig.find(c => c.name === t.name).label : t.label;
                const options = !t.options ? this.defaultToolbarConfig.find(c => c.name === t.name).options : t.options;
                const d = !t.dialogMessage ? this.defaultToolbarConfig.find(c => c.name === t.name).dialogMessage : t.dialogMessage;
                this.toolbarConfig = Object.assign(Object.assign({}, this.toolbarConfig), { [t.name]: { label, options, dialogMessage: d } });
            });
        }
    }
    ngOnDestroy() {
        this.destroy$.next(true);
        this.destroy$.unsubscribe();
    }
    enableEditorOnFocus() {
        if (this.isEnabledOnFocus) {
            this.isReadOnly = false;
        }
    }
    imageUrlHandler() {
        let imageUrlDialogForm = null;
        this.euiDialogService.openDialog(new EuiDialogConfig({
            title: this.toolbarConfig.imageUrl.dialogMessage,
            isHandleCloseOnAccept: true,
            bodyComponent: {
                component: EuiEditorImageDialogComponent,
                config: {
                    onFormValueChange: (form) => {
                        imageUrlDialogForm = form;
                    },
                },
            },
            onAccept: (dialogRef) => {
                if (imageUrlDialogForm && imageUrlDialogForm.valid) {
                    this.euiDialogService.closeDialog(dialogRef);
                    const range = this.quill.getSelection() || { index: 0, length: 0 };
                    this.quill.insertEmbed(range.index, 'image', imageUrlDialogForm.get('url').value, 'user');
                }
            },
        }));
    }
    editorUndo() {
        this.quill['history'].undo();
    }
    editorRedo() {
        this.quill['history'].redo();
    }
    editorDeleteContent() {
        const config = new EuiMessageBoxConfig({
            title: 'Delete content',
            content: '<p>Are you sure you want to delete editor\'s content?</p>',
            hasCloseButton: false,
            accept: () => {
                this.quill.setContents(null);
            },
        });
        this.euiMessageBoxService.openMessageBox(config);
    }
    insertTable() {
        this.tableModule.insertTable(3, 3);
    }
    _onEditorCreated(quill) {
        this.quill = quill;
        if (this.isEnabledOnFocus) {
            this.quill.focus();
        }
        if (this.format === 'html') {
            const delta = this.quill.clipboard.convert({ html: this.value });
            this.formControl.patchValue(delta);
            this.quill.setContents(delta);
        }
        if (this.format === 'json') {
            this.formControl.patchValue(this.value);
            this.quill.setContents(this.value);
        }
        this.editorCreate.emit(quill);
        this.onEditorCreated.emit(quill); // DEPRECATED
    }
    _onEditorChanged(event) {
        this.editorChange.emit(event);
        this.onEditorChanged.emit(event); // DEPRECATED
    }
    _onContentChanged(event) {
        if (this.format === 'html') {
            this.value = event.html;
            this.calculateCounters(this.value);
            this.onChange(this.htmlEntitiesDecode(this.value));
        }
        if (this.format === 'json') {
            if (event.text !== '\n') {
                this.value = event.content;
                this.calculateCounters(event.text);
                this.jsonToHtmlContent = this.htmlEntitiesDecode(JSON.stringify(this.value));
                this.onChange(this.htmlEntitiesDecode(JSON.stringify(this.value)));
            }
            else {
                this.value = null;
                this.calculateCounters('');
                this.jsonToHtmlContent = '';
                this.onChange(null);
            }
        }
        this.contentChange.emit(event);
        this.onContentChanged.emit(event); // DEPRECATED
    }
    _onSelectionChanged(event) {
        this.selectionChange.emit(event);
        this.onSelectionChanged.emit(event); // DEPRECATED
    }
    _onFocus(event) {
        this.isFocused = true;
        this.focus.emit(event);
        this.onFocus.emit(event); // DEPRECATED
    }
    _onBlur(event) {
        this.isFocused = false;
        this.onTouch();
        this.blur.emit(event);
        this.onBlur.emit(event); // DEPRECATED
    }
    registerOnChange(fn) {
        this.onChange = fn;
    }
    registerOnTouched(fn) {
        this.onTouch = fn;
    }
    writeValue(value) {
        this.value = value || null;
        this.jsonToHtmlContent = this.value;
        // PatchValue
        if (this.quill) {
            if (this.format === 'html') {
                const delta = this.quill.clipboard.convert({ html: this.value });
                this.formControl.patchValue(delta);
                this.quill.setContents(delta);
            }
            if (this.format === 'json') {
                this.formControl.patchValue(this.value);
            }
            this.calculateCounters(this.value);
        }
    }
    get tableModule() {
        return this.quill.getModule('better-table');
    }
    htmlEntitiesDecode(content) {
        let c = content;
        if (c) {
            c = c.replace('&amp;', '&');
            c = c.replace('&nbsp;', ' ');
        }
        return c;
    }
    get hasCharactersCounter() {
        return this.toolbarConfig.counters.options.find(o => o.name === 'characters');
    }
    get charactersCounterLabel() {
        var _a;
        return (_a = this.toolbarConfig.counters.options.find(o => o.name === 'characters')) === null || _a === void 0 ? void 0 : _a.label;
    }
    get hasWordsCounter() {
        return this.toolbarConfig.counters.options.find(o => o.name === 'words');
    }
    get wordsCounterLabel() {
        var _a;
        return (_a = this.toolbarConfig.counters.options.find(o => o.name === 'words')) === null || _a === void 0 ? void 0 : _a.label;
    }
    calculateCounters(content) {
        let text;
        if (this.format === 'html') {
            if (content && content.length > 0 && this.quill) {
                text = this.stripHtml(content);
                this.charactersCount = text.length;
                text = this.cleanHtml(content);
                this.wordsCount = !text ? 0 : text.trim().split(/\s+/).length;
            }
            else {
                this.charactersCount = 0;
                this.wordsCount = 0;
                this.bytesCount = 0;
            }
        }
        if (this.format === 'json') {
            if (content && content.length > 0 && this.quill) {
                text = this.stripHtml(this.quill.root.innerHTML);
                this.charactersCount = text.length;
                text = this.cleanHtml(this.quill.root.innerHTML);
                this.wordsCount = !text ? 0 : text.trim().split(/\s+/).length;
            }
            else {
                this.charactersCount = 0;
                this.wordsCount = 0;
                this.bytesCount = 0;
            }
        }
        this.charactersCountChange.emit(this.charactersCount);
        this.getCharactersCounter.emit(this.charactersCount); // DEPRECATED
        this.wordsCountChange.emit(this.wordsCount);
        this.getWordsCounter.emit(this.wordsCount); // DEPRECATED
    }
    stripHtml(content) {
        const regex = /(<([^>]+)>)/gm;
        return content.replace(regex, '');
    }
    cleanHtml(content) {
        const exceptTags = /<strong>|<\/strong>|<b>|<\/b>|<i>|<\/i>|<em>|<\/em>|<s>|<\/s>|<strike>|<\/strike>|<u>|<\/u>/gm;
        const regex = /(<([^>]+)>)/gm;
        return content.replace(exceptTags, '').replace(regex, ' ').replace('  ', ' ');
    }
}
/** @nocollapse */ EuiEditorComponent.ɵfac = function EuiEditorComponent_Factory(t) { return new (t || EuiEditorComponent)(i0.ɵɵdirectiveInject(i1$2.EuiDialogService), i0.ɵɵdirectiveInject(i1$2.EuiMessageBoxService), i0.ɵɵdirectiveInject(i1.NgControl)); };
/** @nocollapse */ EuiEditorComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiEditorComponent, selectors: [["eui-editor"]], contentQueries: function EuiEditorComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
        i0.ɵɵcontentQuery(dirIndex, EuiEditorCustomToolbarTagDirective, true);
    } if (rf & 2) {
        var _t;
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.euiEditorCustomToolbar = _t.first);
    } }, hostVars: 4, hostBindings: function EuiEditorComponent_HostBindings(rf, ctx) { if (rf & 2) {
        i0.ɵɵattribute("readonly", ctx.readonly)("aria-invalid", ctx.isInvalid);
        i0.ɵɵclassProp("eui-editor", true);
    } }, inputs: { e2eAttr: "e2eAttr", id: "id", styleClass: "styleClass", placeholder: "placeholder", format: "format", isReadOnly: "isReadOnly", theme: "theme", debug: "debug", customToolbarPosition: "customToolbarPosition", tabindex: "tabindex", showCounters: "showCounters", modules: "modules", isEnabledOnFocus: "isEnabledOnFocus", isMinimalToolbar: "isMinimalToolbar", style: "style", formats: "formats", customToolbarOptions: "customToolbarOptions", maxLength: "maxLength", minLength: "minLength", isRequired: "isRequired", isEditable: "isEditable", formControlName: "formControlName", feedbackTypeClass: "feedbackTypeClass", validationErrorMessage: "validationErrorMessage", hasReadOnlyStyles: "hasReadOnlyStyles", strict: "strict", scrollingContainer: "scrollingContainer", bounds: "bounds", customOptions: "customOptions", trackChanges: "trackChanges", preserveWhitespace: "preserveWhitespace", spellcheck: "spellcheck", isImageUrl: "isImageUrl", customToolbarConfig: "customToolbarConfig", height: "height" }, outputs: { onInit: "onInit", onTextChange: "onTextChange", onSelectionChange: "onSelectionChange", onEditorCreated: "onEditorCreated", onEditorChanged: "onEditorChanged", onContentChanged: "onContentChanged", onSelectionChanged: "onSelectionChanged", onFocus: "onFocus", onBlur: "onBlur", getCharactersCounter: "getCharactersCounter", getWordsCounter: "getWordsCounter", editorCreate: "editorCreate", editorChange: "editorChange", contentChange: "contentChange", selectionChange: "selectionChange", focus: "focus", blur: "blur", charactersCountChange: "charactersCountChange", wordsCountChange: "wordsCountChange" }, ngContentSelectors: _c1, decls: 7, vars: 31, consts: [[1, "eui-editor-wrapper", 3, "hidden"], [3, "id", "format", "sanitize", "modules", "theme", "placeholder", "styles", "customToolbarPosition", "formControl", "debug", "tabindex", "customModules", "onEditorCreated", "onEditorChanged", "onContentChanged", "onSelectionChanged", "onFocus", "onBlur"], ["quill-editor-toolbar", "", 4, "ngIf"], [3, "hidden", "tabindex", "click", "focusin"], [3, "content", "theme", 4, "ngIf"], ["quill-editor-toolbar", ""], ["class", "ql-formats", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-formats", 4, "ngIf"], [1, "ql-formats", 3, "euiTooltip"], [1, "ql-header"], [3, "value", 4, "ngFor", "ngForOf"], ["selected", ""], [3, "value"], [1, "ql-font"], ["value", "serif"], ["value", "monospace"], [1, "ql-formats"], ["class", "ql-bold", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-italic", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-underline", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-strike", 3, "euiTooltip", 4, "ngIf"], [1, "ql-bold", 3, "euiTooltip"], [1, "ql-italic", 3, "euiTooltip"], [1, "ql-underline", 3, "euiTooltip"], [1, "ql-strike", 3, "euiTooltip"], [3, "euiTooltip", 4, "ngIf"], [3, "euiTooltip"], [1, "ql-color"], [1, "ql-background"], ["class", "ql-script", "value", "sub", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-script", "value", "super", 3, "euiTooltip", 4, "ngIf"], ["value", "sub", 1, "ql-script", 3, "euiTooltip"], ["value", "super", 1, "ql-script", 3, "euiTooltip"], [1, "ql-align"], ["value", "center"], ["value", "right"], ["value", "justify"], ["class", "ql-list", "value", "ordered", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-list", "value", "bullet", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-indent", "value", "-1", "type", "button", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-indent", "value", "+1", "type", "button", 3, "euiTooltip", 4, "ngIf"], ["value", "ordered", 1, "ql-list", 3, "euiTooltip"], ["value", "bullet", 1, "ql-list", 3, "euiTooltip"], ["value", "-1", "type", "button", 1, "ql-indent", 3, "euiTooltip"], ["value", "+1", "type", "button", 1, "ql-indent", 3, "euiTooltip"], ["class", "ql-blockquote", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-code-block", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-link", 3, "euiTooltip", 4, "ngIf"], ["class", "ql-image", 3, "euiTooltip", 4, "ngIf"], [3, "euiTooltip", "click", 4, "ngIf"], ["class", "ql-video", 3, "euiTooltip", 4, "ngIf"], [1, "ql-blockquote", 3, "euiTooltip"], [1, "ql-code-block", 3, "euiTooltip"], [1, "ql-link", 3, "euiTooltip"], [1, "ql-image", 3, "euiTooltip"], [3, "euiTooltip", "click"], [1, "eui-icon", "eui-icon-image-add"], [1, "ql-video", 3, "euiTooltip"], [1, "eui-icon", "eui-icon-ecl-spreadsheet"], ["class", "ql-clean", 3, "euiTooltip", 4, "ngIf"], [1, "ql-clean", 3, "euiTooltip"], [1, "eui-icon", "eui-icon-delete-forever"], [1, "eui-icon", "eui-icon-undo"], [1, "eui-icon", "eui-icon-redo"], [3, "hasCharactersCounter", "charactersCounter", "charactersLabel", "hasWordsCounter", "wordsCounter", "wordsLabel", "euiTooltip"], [3, "content", "theme"]], template: function EuiEditorComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵprojectionDef(_c0);
        i0.ɵɵelementStart(0, "div", 0);
        i0.ɵɵelementStart(1, "quill-editor", 1);
        i0.ɵɵlistener("onEditorCreated", function EuiEditorComponent_Template_quill_editor_onEditorCreated_1_listener($event) { return ctx._onEditorCreated($event); })("onEditorChanged", function EuiEditorComponent_Template_quill_editor_onEditorChanged_1_listener($event) { return ctx._onEditorChanged($event); })("onContentChanged", function EuiEditorComponent_Template_quill_editor_onContentChanged_1_listener($event) { return ctx._onContentChanged($event); })("onSelectionChanged", function EuiEditorComponent_Template_quill_editor_onSelectionChanged_1_listener($event) { return ctx._onSelectionChanged($event); })("onFocus", function EuiEditorComponent_Template_quill_editor_onFocus_1_listener($event) { return ctx._onFocus($event); })("onBlur", function EuiEditorComponent_Template_quill_editor_onBlur_1_listener($event) { return ctx._onBlur($event); });
        i0.ɵɵtemplate(2, EuiEditorComponent_div_2_Template, 12, 11, "div", 2);
        i0.ɵɵtemplate(3, EuiEditorComponent_div_3_Template, 2, 0, "div", 2);
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(4, "div", 3);
        i0.ɵɵlistener("click", function EuiEditorComponent_Template_div_click_4_listener() { return ctx.enableEditorOnFocus(); })("focusin", function EuiEditorComponent_Template_div_focusin_4_listener() { return ctx.enableEditorOnFocus(); });
        i0.ɵɵtemplate(5, EuiEditorComponent_eui_editor_html_view_5_Template, 1, 2, "eui-editor-html-view", 4);
        i0.ɵɵtemplate(6, EuiEditorComponent_eui_editor_json_view_6_Template, 1, 2, "eui-editor-json-view", 4);
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵstyleProp("height", ctx.height + "px");
        i0.ɵɵproperty("hidden", ctx.isReadOnly);
        i0.ɵɵadvance(1);
        i0.ɵɵclassMapInterpolate1("eui-editor ", ctx.styleClass, "");
        i0.ɵɵclassProp("eui-editor--focused", ctx.isFocused);
        i0.ɵɵproperty("id", ctx.generatedId)("format", ctx.format)("sanitize", true)("modules", ctx.modules)("theme", ctx.theme)("placeholder", ctx.placeholder)("styles", ctx.style)("customToolbarPosition", ctx.customToolbarPosition)("formControl", ctx.formControl)("debug", ctx.debug)("tabindex", ctx.tabindex)("customModules", ctx.customModules);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.euiEditorCustomToolbar && ctx.toolbarConfig);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.euiEditorCustomToolbar);
        i0.ɵɵadvance(1);
        i0.ɵɵclassMapInterpolate1("eui-editor eui-editor--readonly ", ctx.styleClass, "");
        i0.ɵɵclassProp("eui-editor--empty", !ctx.value);
        i0.ɵɵpropertyInterpolate("tabindex", ctx.tabindex);
        i0.ɵɵproperty("hidden", !ctx.isReadOnly);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.format === "html");
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.format === "json");
    } }, directives: [i3.QuillEditorComponent, i1.NgControlStatus, i1.FormControlDirective, i4.NgIf, i1$2.EuiTooltipDirective, i4.NgForOf, i1.NgSelectOption, i1.ɵangular_packages_forms_forms_x, EuiEditorCountersComponent, EuiEditorHtmlViewComponent, EuiEditorJsonViewComponent], styles: [".qlbt-operation-menu .qlbt-operation-color-picker{padding:0 12px 10px!important}.eui-editor .ql-container{box-sizing:border-box;font-size:var(--eui-font-size);font-style:normal;font-weight:400;height:100%;margin:0;position:relative;resize:vertical}.eui-editor .ql-container .ql-tooltip.ql-editing{position:absolute;right:50%;top:var(--eui-spacing);transform:translateX(50%)}.eui-editor .ql-toolbar{background-color:var(--eui-color-grey-lightester-2);border:1px solid var(--eui-color-grey-lighter);font-style:normal;font-weight:400;padding:var(--eui-spacing-xs) var(--eui-spacing-xs) 0 var(--eui-spacing-xs)}.eui-editor .ql-toolbar.ql-snow button{background:none;border:none;cursor:pointer;display:inline-flex;padding:3px 5px;width:28px}.eui-editor .ql-toolbar.ql-snow .ql-formats{align-items:center;background-color:var(--eui-color-grey-lightester);border:1px solid var(--eui-color-grey-lighter);border-radius:5px;display:inline-flex;margin-bottom:var(--eui-spacing-xs);margin-right:var(--eui-spacing-xs);vertical-align:middle}.eui-editor .ql-toolbar.ql-snow .ql-formats .ql-picker{align-items:center;color:var(--eui-color-grey-darker);display:inline-flex;font-size:var(--eui-font-size);height:var(--eui-spacing-xl);max-height:var(--eui-spacing-xl);position:relative;vertical-align:middle}.eui-editor .ql-toolbar.ql-snow .ql-formats .ql-picker.ql-expanded .ql-picker-label{border-color:transparent}.eui-editor .ql-toolbar.ql-snow .ql-formats button{align-items:center;background-color:initial;border:0 solid var(--eui-color-grey-lighter);box-shadow:none;color:var(--eui-color-grey-darker);display:inline-flex;height:var(--eui-spacing-xl);justify-content:center;min-width:var(--eui-spacing-xl);padding:var(--eui-spacing-1xs)}.eui-editor .ql-toolbar.ql-snow .ql-formats button:hover{color:var(--eui-color-info)}.eui-editor .ql-toolbar.ql-snow .ql-formats button.active,.eui-editor .ql-toolbar.ql-snow .ql-formats button.ql-active{background:var(--eui-color-accent);color:var(--eui-color-primary)}.eui-editor .ql-toolbar.ql-snow .ql-formats button:first-child{border-radius:5px 0 0 5px}.eui-editor .ql-toolbar.ql-snow .ql-formats button:last-child{border-radius:0 5px 5px 0}.eui-editor .ql-toolbar.ql-snow .ql-formats button .eui-icon{font-size:var(--eui-font-size-2xl)}.eui-editor .ql-toolbar.ql-snow .ql-formats button:active,.eui-editor .ql-toolbar.ql-snow .ql-formats button:focus{border-color:var(--eui-color-accessible-focus)!important;box-shadow:inset 0 0 0 1px var(--eui-color-accessible-focus),inset 0 0 0 2px var(--eui-color-grey-lightester);outline:none;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;z-index:auto}.eui-editor .ql-toolbar.ql-snow .ql-formats button.editor-counters{align-items:center;display:inline-flex;width:auto}.eui-editor .ql-toolbar.ql-snow .ql-formats button.editor-counters .bytes-counter,.eui-editor .ql-toolbar.ql-snow .ql-formats button.editor-counters .chars-counter,.eui-editor .ql-toolbar.ql-snow .ql-formats button.editor-counters .words-counter{color:var(--eui-color-info);font-size:var(--eui-font-size-s);font-weight:900}.eui-editor .ql-toolbar.ql-snow .ql-formats button.editor-counters .bytes-counter.chars-counter--error,.eui-editor .ql-toolbar.ql-snow .ql-formats button.editor-counters .chars-counter.chars-counter--error,.eui-editor .ql-toolbar.ql-snow .ql-formats button.editor-counters .words-counter.chars-counter--error{color:var(--eui-color-danger)}.eui-editor .ql-toolbar.ql-snow .ql-formats button.editor-counters .bytes-label,.eui-editor .ql-toolbar.ql-snow .ql-formats button.editor-counters .chars-label,.eui-editor .ql-toolbar.ql-snow .ql-formats button.editor-counters .words-label{color:var(--eui-color-grey-dark);font-size:var(--eui-font-size-xs)}.eui-editor .ql-toolbar.ql-snow .ql-formats select{background-color:initial;border:.5px solid var(--eui-color-black);border-radius:5px;cursor:pointer;font-size:var(--eui-font-size-s);outline:0;padding:.4rem;vertical-align:middle;width:90px}.eui-editor .ql-toolbar.ql-snow .ql-formats select:active,.eui-editor .ql-toolbar.ql-snow .ql-formats select:focus{border-color:var(--eui-color-accessible-focus)!important;box-shadow:inset 0 0 0 1px var(--eui-color-accessible-focus),inset 0 0 0 2px var(--eui-color-grey-lightester);outline:none;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;z-index:auto}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker{height:var(--eui-spacing-xl);padding:var(--eui-spacing-2xs) 0;width:calc(var(--eui-spacing)*7)}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item:before,.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-label:before{content:\"Normal\"}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item[data-value=small]:before,.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-label[data-value=small]:before{content:\"Small\"}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item[data-value=smaller]:before,.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-label[data-value=smaller]:before{content:\"Smaller\"}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item[data-value=smallest]:before,.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-label[data-value=smallest]:before{content:\"Smallest\"}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item[data-value=large]:before,.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-label[data-value=large]:before{content:\"Large\"}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item[data-value=huge]:before,.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-label[data-value=huge]:before{content:\"Huge\"}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item[data-value=small]:before,.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-size-small{font-size:var(--eui-font-size-s)}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item[data-value=smaller]:before{font-size:var(--eui-font-size-xs)}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item[data-value=smallest]:before{font-size:var(--eui-font-size-2xs)}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item[data-value=large]:before,.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-size-large{font-size:var(--eui-font-size-xl)}.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-picker-item[data-value=huge]:before,.eui-editor .ql-toolbar.ql-snow .ql-size.ql-picker .ql-size-huge{font-size:var(--eui-font-size-4xl)}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker{height:var(--eui-spacing-xl);padding:var(--eui-spacing-2xs) 0;width:calc(var(--eui-spacing)*8)}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item:before,.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-label:before{content:\"Normal\"}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"1\"]:before,.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-label[data-value=\"1\"]:before{content:\"Heading 1\"}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"2\"]:before,.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-label[data-value=\"2\"]:before{content:\"Heading 2\"}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"3\"]:before,.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-label[data-value=\"3\"]:before{content:\"Heading 3\"}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"4\"]:before,.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-label[data-value=\"4\"]:before{content:\"Heading 4\"}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"5\"]:before,.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-label[data-value=\"5\"]:before{content:\"Heading 5\"}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"6\"]:before,.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-label[data-value=\"6\"]:before{content:\"Heading 6\"}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"1\"]:before{font-size:var(--eui-font-size-4xl)}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"2\"]:before{font-size:var(--eui-font-size-3xl)}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"3\"]:before{font-size:var(--eui-font-size-2xl)}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"4\"]:before{font-size:var(--eui-font-size-xl)}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"5\"]:before{font-size:var(--eui-font-size-l)}.eui-editor .ql-toolbar.ql-snow .ql-header.ql-picker .ql-picker-item[data-value=\"6\"]:before{font-size:var(--eui-font-size-m)}.eui-editor .ql-toolbar.ql-snow .ql-font.ql-picker{height:var(--eui-spacing-xl);padding:var(--eui-spacing-2xs) 0;width:calc(var(--eui-spacing)*8)}.eui-editor .ql-toolbar.ql-snow .ql-font.ql-picker .ql-picker-item:before,.eui-editor .ql-toolbar.ql-snow .ql-font.ql-picker .ql-picker-label:before{content:\"Sans Serif\"}.eui-editor .ql-toolbar.ql-snow .ql-font.ql-picker .ql-picker-item[data-value=serif]:before,.eui-editor .ql-toolbar.ql-snow .ql-font.ql-picker .ql-picker-label[data-value=serif]:before{content:\"Serif\"}.eui-editor .ql-toolbar.ql-snow .ql-font.ql-picker .ql-picker-item[data-value=monospace]:before,.eui-editor .ql-toolbar.ql-snow .ql-font.ql-picker .ql-picker-label[data-value=monospace]:before{content:\"Monospace\"}.eui-editor .ql-toolbar.ql-snow .ql-font.ql-picker .ql-picker-item[data-value=sans-serif]:before{font-family:arial,sans-serif!important}.eui-editor .ql-toolbar.ql-snow .ql-font.ql-picker .ql-picker-item[data-value=serif]:before{font-family:times new roman,serif!important}.eui-editor .ql-toolbar.ql-snow .ql-font.ql-picker .ql-picker-item[data-value=monospace]:before{font-family:courier new,monospace!important}.eui-editor .ql-toolbar.ql-snow .ql-color-picker{width:var(--eui-spacing-xl)}.eui-editor .ql-toolbar .eui-editor-custom-toolbar{display:inline-flex;margin:0;padding:0;vertical-align:middle}.eui-editor .ql-editor{box-sizing:border-box;font-style:normal;font-weight:400;height:100%;line-height:var(--eui-line-height-base);outline:none;overflow-y:auto;padding:var(--eui-spacing-s);tab-size:4;text-align:left;white-space:pre-wrap;word-break:normal;word-wrap:break-word}.eui-editor .ql-editor h1{font-size:var(--eui-font-size-4xl)!important}.eui-editor .ql-editor h2{font-size:var(--eui-font-size-3xl)!important}.eui-editor .ql-editor h3{font-size:var(--eui-font-size-2xl)!important}.eui-editor .ql-editor h4{font-size:var(--eui-font-size-xl)!important}.eui-editor .ql-editor h5{font-size:var(--eui-font-size-l)!important}.eui-editor .ql-editor h6{font-size:var(--eui-font-size-m)!important}.eui-editor .ql-editor .h7{font-size:var(--eui-font-size-s)!important}.eui-editor .ql-editor .h8{font-size:var(--eui-font-size-xs)!important}.eui-editor .ql-editor .h9{font-size:var(--eui-font-size-2xs)!important}.eui-editor .ql-editor em,.eui-editor .ql-editor i{font-style:italic!important}.eui-editor .ql-editor b,.eui-editor .ql-editor strong{font-weight:700!important}.eui-editor .ql-editor b em,.eui-editor .ql-editor b i,.eui-editor .ql-editor strong em,.eui-editor .ql-editor strong i{font-style:italic!important;font-weight:700!important}.eui-editor .ql-editor b em u,.eui-editor .ql-editor b i u,.eui-editor .ql-editor strong em u,.eui-editor .ql-editor strong i u{text-decoration:underline!important}.eui-editor .ql-editor blockquote{border-left:var(--eui-spacing-xs) solid var(--eui-color-grey-light);margin-bottom:0;margin-top:0;padding-left:var(--eui-spacing)}.eui-editor .ql-editor code,.eui-editor .ql-editor pre{background-color:#f0f0f0;border-radius:3px}.eui-editor .ql-editor pre{margin-bottom:var(--eui-spacing-xs);margin-top:var(--eui-spacing-xs);padding:var(--eui-spacing-xs) var(--eui-spacing-m);white-space:pre-wrap}.eui-editor .ql-editor code{font-size:85%;padding:2px 4px;word-break:break-word}.eui-editor .ql-editor ol{counter-reset:inherit;list-style:none}.eui-editor .ql-editor ol li{padding-left:var(--eui-spacing-s)}.eui-editor .ql-editor ol li[data-list=bullet]{list-style:none}.eui-editor .ql-editor ol li[data-list=bullet]>.ql-ui:before{content:\"\\2022\";font-size:var(--eui-font-size-xl);margin-left:calc(var(--eui-spacing-m)*-2.125);position:absolute;top:calc(var(--eui-spacing-2xs)*-0.75)}.eui-editor .ql-editor ol li[data-list=ordered]{list-style:none}.eui-editor .ql-editor pre.ql-syntax{background-color:var(--eui-color-grey-dark);color:#f5f5f5;overflow:visible}.eui-editor .ql-editor iframe,.eui-editor .ql-editor img{display:inline-block;height:1;width:1}.eui-editor .ql-editor.ql-blank:before{left:var(--eui-spacing);position:absolute;right:0}.eui-editor.eui-editor--focused .ql-container{box-shadow:0 1px 0 rgba(0,0,0,.08),0 1px 1px rgba(0,0,0,.08);outline:1px solid var(--eui-color-primary)}.eui-editor.eui-editor--readonly .ql-container{border:none}.eui-editor.eui-editor--readonly .ql-editor{min-height:calc(var(--eui-spacing-2xl) + 2px);padding:0 0 var(--eui-spacing) 0}.eui-editor.eui-editor--readonly.eui-editor--empty .ql-container{border:none;outline:1px dashed var(--eui-color-grey-lighter)}.eui-editor.eui-editor--readonly.eui-editor--empty .ql-container:hover{outline:1px solid var(--eui-color-grey-light)}.eui-editor-wrapper{position:relative}.eui-editor-wrapper .eui-editor{display:flex;flex-direction:column;height:100%;position:relative;width:100%}.eui-editor-wrapper .eui-editor .ql-container{background-color:var(--eui-color-white);border:1px solid #ccc;flex-grow:1;padding:.35rem}.eui-editor-wrapper .eui-editor .ql-container .ngx-quill-view{border:0}eui-editor{position:relative;width:100%}eui-editor.ng-invalid.ng-touched .eui-editor:not(.eui-editor--readonly) .ql-container{outline:1px solid var(--eui-color-danger)}.ql-container .qlbt-selection-line.qlbt-selection-line-left:before{background-color:#0589f3;border-radius:5px;content:\"\";height:5px;left:-2px;position:absolute;top:-2px;width:5px}.ql-container .qlbt-selection-line.qlbt-selection-line-right:before{background-color:#0589f3;border-radius:5px;bottom:-3px;content:\"\";height:5px;position:absolute;right:-2px;width:5px}.quill-better-table-wrapper{overflow-x:auto}table.quill-better-table{border-collapse:collapse;table-layout:fixed}table.quill-better-table td{border:1px solid #000;padding:2px 5px}.qlbt-operation-menu{background-color:#fff;box-shadow:0 2px 8px rgba(0,0,0,.15);font-size:14px;overflow:hidden;z-index:100}.qlbt-operation-menu .qlbt-operation-menu-dividing{background-color:#efefef;height:1px}.qlbt-operation-menu .qlbt-operation-menu-subtitle{color:#999;font-size:14px;padding:5px 16px}.qlbt-operation-menu .qlbt-operation-color-picker{align-items:center;background-color:#fff;display:flex;flex-wrap:wrap;overflow:hidden;padding:0 16px 10px}.qlbt-operation-menu .qlbt-operation-color-picker .qlbt-operation-color-picker-item{border:1px solid #595959;cursor:pointer;height:20px;margin-bottom:5px;margin-right:5px;width:20px}.qlbt-operation-menu .qlbt-operation-menu-item{align-items:center;background-color:#fff;color:#595959;cursor:pointer;display:flex;overflow:hidden;padding:10px 16px;text-overflow:ellipsis}.qlbt-operation-menu .qlbt-operation-menu-item:hover{background-color:#efefef}.qlbt-operation-menu .qlbt-operation-menu-item .qlbt-operation-menu-icon{font-size:0;height:20px;margin-right:8px;width:20px}.qlbt-col-tool{align-items:flex-end;display:flex;height:16px;overflow:hidden;position:absolute;z-index:99}.qlbt-col-tool .qlbt-col-tool-cell{background-color:#fff;border-bottom:1px solid #000;border-right:1px solid #000;border-top:1px solid #000;position:relative}.qlbt-col-tool .qlbt-col-tool-cell:first-child{border-left:1px solid #000}.qlbt-col-tool .qlbt-col-tool-cell-holder{background-color:initial;bottom:0;cursor:ew-resize;position:absolute;right:-1px;top:0;width:1px;z-index:3}.qlbt-col-tool .qlbt-col-tool-cell-holder:hover{background-color:#0589f3}.qlbt-col-tool .qlbt-col-tool-cell-holder:before{content:\"\";display:block;height:100%;left:-6px;position:absolute;top:0;width:8px}.qlbt-col-tool .qlbt-col-tool-cell-holder:after{content:\"\";display:block;height:100%;position:absolute;right:-6px;top:0;width:8px}"], encapsulation: 2, changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiEditorComponent, [{
        type: Component,
        args: [{
                // tslint:disable-next-line
                selector: 'eui-editor',
                templateUrl: './eui-editor.component.html',
                styleUrls: ['./styles/_index.scss'],
                encapsulation: ViewEncapsulation.None,
                changeDetection: ChangeDetectionStrategy.OnPush,
            }]
    }], function () { return [{ type: i1$2.EuiDialogService }, { type: i1$2.EuiMessageBoxService }, { type: i1.NgControl }]; }, { e2eAttr: [{
            type: Input
        }], id: [{
            type: Input
        }], styleClass: [{
            type: Input
        }], placeholder: [{
            type: Input
        }], format: [{
            type: Input
        }], isReadOnly: [{
            type: Input
        }], theme: [{
            type: Input
        }], debug: [{
            type: Input
        }], customToolbarPosition: [{
            type: Input
        }], tabindex: [{
            type: Input
        }], showCounters: [{
            type: Input
        }], modules: [{
            type: Input
        }], isEnabledOnFocus: [{
            type: Input
        }], isMinimalToolbar: [{
            type: Input
        }], style: [{
            type: Input
        }], formats: [{
            type: Input
        }], customToolbarOptions: [{
            type: Input
        }], maxLength: [{
            type: Input
        }], minLength: [{
            type: Input
        }], isRequired: [{
            type: Input
        }], isEditable: [{
            type: Input
        }], formControlName: [{
            type: Input
        }], feedbackTypeClass: [{
            type: Input
        }], validationErrorMessage: [{
            type: Input
        }], hasReadOnlyStyles: [{
            type: Input
        }], strict: [{
            type: Input
        }], scrollingContainer: [{
            type: Input
        }], bounds: [{
            type: Input
        }], customOptions: [{
            type: Input
        }], trackChanges: [{
            type: Input
        }], preserveWhitespace: [{
            type: Input
        }], spellcheck: [{
            type: Input
        }], isImageUrl: [{
            type: Input
        }], customToolbarConfig: [{
            type: Input
        }], height: [{
            type: Input
        }], onInit: [{
            type: Output
        }], onTextChange: [{
            type: Output
        }], onSelectionChange: [{
            type: Output
        }], onEditorCreated: [{
            type: Output
        }], onEditorChanged: [{
            type: Output
        }], onContentChanged: [{
            type: Output
        }], onSelectionChanged: [{
            type: Output
        }], onFocus: [{
            type: Output
        }], onBlur: [{
            type: Output
        }], getCharactersCounter: [{
            type: Output
        }], getWordsCounter: [{
            type: Output
        }], editorCreate: [{
            type: Output
        }], editorChange: [{
            type: Output
        }], contentChange: [{
            type: Output
        }], selectionChange: [{
            type: Output
        }], focus: [{
            type: Output
        }], blur: [{
            type: Output
        }], charactersCountChange: [{
            type: Output
        }], wordsCountChange: [{
            type: Output
        }], true: [{
            type: HostBinding,
            args: ['class.eui-editor']
        }], readonly: [{
            type: HostBinding,
            args: ['attr.readonly']
        }], isInvalid: [{
            type: HostBinding,
            args: ['attr.aria-invalid']
        }], euiEditorCustomToolbar: [{
            type: ContentChild,
            args: [forwardRef(() => EuiEditorCustomToolbarTagDirective), { static: false }]
        }] }); })();
/* tslint:disable */
class EuiEditorCustomToolbarTagDirective {
    constructor() {
        this.elementClass = 'eui-editor-custom-toolbar';
    }
}
/** @nocollapse */ EuiEditorCustomToolbarTagDirective.ɵfac = function EuiEditorCustomToolbarTagDirective_Factory(t) { return new (t || EuiEditorCustomToolbarTagDirective)(); };
/** @nocollapse */ EuiEditorCustomToolbarTagDirective.ɵdir = i0.ɵɵdefineDirective({ type: EuiEditorCustomToolbarTagDirective, selectors: [["euiEditorCustomToolbar"]], hostVars: 2, hostBindings: function EuiEditorCustomToolbarTagDirective_HostBindings(rf, ctx) { if (rf & 2) {
        i0.ɵɵclassMap(ctx.elementClass);
    } } });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiEditorCustomToolbarTagDirective, [{
        type: Directive,
        args: [{ selector: 'euiEditorCustomToolbar' }]
    }], null, { elementClass: [{
            type: HostBinding,
            args: ['class']
        }] }); })();

class EuiEditorMaxlengthDirective {
    constructor(el, renderer, control) {
        this.el = el;
        this.renderer = renderer;
        this.control = control;
        this.isShowMaxlength = true;
        this.format = 'html';
    }
    ngOnChanges(changes) {
        if (changes['isShowMaxlength'] && this.maxLengthSpan) {
            if (this.isShowMaxlength) {
                this.createMaxLengthBox();
                this.refreshValue();
            }
            else {
                this.destroyMaxLengthBox();
            }
        }
    }
    ngAfterContentInit() {
        var _a;
        if (this.euiEditorMaxlength) {
            this.createMaxLengthBox();
            this.refreshValue();
        }
        if ((_a = this.control) === null || _a === void 0 ? void 0 : _a.valueChanges) {
            this.valueChangesSubscription = this.control.valueChanges.subscribe(() => {
                this.refreshValue();
            });
        }
    }
    ngOnDestroy() {
        this.destroyMaxLengthBox();
        if (this.valueChangesSubscription) {
            this.valueChangesSubscription.unsubscribe();
        }
    }
    refreshValue() {
        let valueLength = 0;
        let remainingLength = 0;
        if (this.format === 'html') {
            const regex = /(<([^>]+)>)/ig;
            const tagsStrippedContent = this.control.value ? this.control.value.replace(regex, '') : '';
            valueLength = tagsStrippedContent.length;
            remainingLength = this.euiEditorMaxlength - valueLength;
        }
        else {
            const content = this.control.value && this.control.value !== '' ? JSON.parse(this.control.value).ops
                .filter((c) => typeof (c.insert) === 'string')
                .map((c) => c.insert.replace(/\n/g, '')) : [''];
            const jsonStrippedContent = content.join('');
            valueLength = jsonStrippedContent.length;
            remainingLength = this.euiEditorMaxlength - valueLength;
        }
        if (remainingLength < 0 && this.maxLengthSpan) {
            this.maxLengthSpan.classList.add('error');
            this.maxLengthSpan.innerHTML = '0';
        }
        else {
            // if (remainingLength <= 0 && this.maxLengthSpan) {
            //     this.maxLengthSpan.classList.add('error');
            // }
            if (remainingLength >= 0 && this.maxLengthSpan) {
                this.maxLengthSpan.innerHTML = (this.euiEditorMaxlength - valueLength).toString();
                this.maxLengthSpan.classList.remove('error');
            }
            // if (remainingLength >= 0 && this.maxLengthSpan) {
            //     this.maxLengthSpan.classList.remove('error');
            // }
        }
    }
    createMaxLengthBox() {
        this.maxLengthSpan = this.renderer.createElement('span');
        this.renderer.addClass(this.maxLengthSpan, 'input-maxlength');
        this.renderer.setAttribute(this.maxLengthSpan, 'innerHTML', this.euiEditorMaxlength.toString());
        let nativeElement = this.el.nativeElement;
        if (nativeElement != null) {
            this.renderer.setStyle(nativeElement, 'width', '100%');
            let parent = nativeElement.parentNode;
            if (parent != null && this.isShowMaxlength) {
                this.wrapper = this.renderer.createElement('div');
                this.renderer.addClass(this.wrapper, 'input-maxlength-wrapper');
                parent.replaceChild(this.wrapper, nativeElement);
                this.renderer.appendChild(this.wrapper, nativeElement);
                this.renderer.appendChild(this.wrapper, this.maxLengthSpan);
            }
        }
    }
    destroyMaxLengthBox() {
        if (this.maxLengthSpan) {
            this.renderer.removeChild(this.maxLengthSpan.parentElement, this.maxLengthSpan);
        }
        if (this.wrapper) {
            let parent = this.wrapper.parentNode;
            let nativeElement = this.el.nativeElement;
            parent.replaceChild(nativeElement, this.wrapper);
            this.renderer.removeChild(this.wrapper.parentElement, this.wrapper);
        }
    }
}
/** @nocollapse */ EuiEditorMaxlengthDirective.ɵfac = function EuiEditorMaxlengthDirective_Factory(t) { return new (t || EuiEditorMaxlengthDirective)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i1.NgControl, 2)); };
/** @nocollapse */ EuiEditorMaxlengthDirective.ɵdir = i0.ɵɵdefineDirective({ type: EuiEditorMaxlengthDirective, selectors: [["", "formControlName", "", "euiEditorMaxlength", ""]], inputs: { euiEditorMaxlength: "euiEditorMaxlength", isShowMaxlength: "isShowMaxlength", format: "format" }, features: [i0.ɵɵNgOnChangesFeature] });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiEditorMaxlengthDirective, [{
        type: Directive,
        args: [{
                /* tslint:disable-next-line */
                selector: '[formControlName][euiEditorMaxlength]',
            }]
    }], function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.NgControl, decorators: [{
                type: Self
            }] }]; }, { euiEditorMaxlength: [{
            type: Input
        }], isShowMaxlength: [{
            type: Input
        }], format: [{
            type: Input
        }] }); })();

const isJson = (value) => {
    try {
        JSON.parse(value);
    }
    catch (e) {
        return false;
    }
    return true;
};
const byteLength = (value) => {
    // returns the byte length of an utf8 string
    let s = value.length;
    for (let i = value.length - 1; i >= 0; i--) {
        const code = value.charCodeAt(i);
        if (code > 0x7f && code <= 0x7ff) {
            s++;
        }
        else if (code > 0x7ff && code <= 0xffff) {
            s += 2;
        }
        if (code >= 0xDC00 && code <= 0xDFFF) {
            i--;
        }
    }
    return s;
};
/**
 * @description
 * Validator that requires the length of the editor's content, out of HTML tags or JSON structure, to be greater than or equal
 * to the provided minimum length.
 *
 * @usageNotes
 * Validate that the editor has a minimum of 5 characters:
 *
 * ```typescript
 * const editor = new FormControl('ng', euiEditorMinLength(5));
 * console.log(editor.errors); // { minlength: { minLength: 5, actual: 2 } }
 * ```
 *
 * @returns A validator function that returns an error map with the
 * `minlength` if the validation check fails, otherwise `null`.
 */
const euiEditorMinLength = (minLength) => {
    return (control) => {
        if (control.value) {
            let actual = 0;
            if (isJson(control.value)) {
                const content = JSON.parse(control.value).ops
                    .filter((c) => typeof (c.insert) === 'string')
                    .map((c) => c.insert.replace(/\n/g, ''));
                const jsonStrippedContent = content.join('');
                actual = jsonStrippedContent.length;
            }
            else {
                const regex = /(<([^>]+)>)/ig;
                const tagsStrippedContent = control.value.replace(regex, '');
                actual = tagsStrippedContent.length;
            }
            return actual < minLength ? { 'minLength': { minLength, actual } } : null;
        }
    };
};
/**
 * @description
 * Validator that requires the length of the editor's content, out of HTML tags or JSON structure, to be less than or equal
 * to the provided maximum length.
 *
 * @usageNotes
 * Validate that the editor has a maximum of 10 characters:
 *
 * ```typescript
 * const editor = new FormControl('ng angular reactive', euiEditorMaxLength(10));
 * console.log(editor.errors); // { maxLength: { maxLength: 10, actual: 19 } }
 * ```
 *
 * @returns A validator function that returns an error map with the
 * `maxlength` if the validation check fails, otherwise `null`.
 */
const euiEditorMaxLength = (maxLength) => {
    return (control) => {
        if (control.value) {
            let actual = 0;
            if (isJson(control.value)) {
                const content = JSON.parse(control.value).ops
                    .filter((c) => typeof (c.insert) === 'string')
                    .map((c) => c.insert.replace(/\n/g, ''));
                const jsonStrippedContent = content.join('');
                actual = jsonStrippedContent.length;
            }
            else {
                const exceptTags = /<strong>|<\/strong>|<b>|<\/b>|<i>|<\/i>|<em>|<\/em>|<s>|<\/s>|<strike>|<\/strike>|<u>|<\/u>/gm;
                const regex = /(<([^>]+)>)/ig;
                const tagsStrippedContent = control.value.replace(exceptTags, '').replace(regex, '').replace('  ', ' ');
                actual = tagsStrippedContent.length;
            }
            return actual > maxLength ? { 'maxLength': { maxLength, actual } } : null;
        }
    };
};
/**
 * @description
 * Validator that requires the number of words in the editor, out of HTML tags or JSON structure, to be greater than or equal
 * to the provided minimum number.
 *
 * @usageNotes
 * Validate that the editor has a minimum of 5 words:
 *
 * ```typescript
 * const editor = new FormControl('ng angular', euiEditorMinWords(5));
 * console.log(editor.errors); // { minWords: { minWords: 5, actual: 2 } }
 * ```
 *
 * @returns A validator function that returns an error map with the
 * `minWords` if the validation check fails, otherwise `null`.
 */
const euiEditorMinWords = (minWords) => {
    return (control) => {
        if (control.value) {
            let actual = 0;
            if (isJson(control.value)) {
                const content = JSON.parse(control.value).ops
                    .filter((c) => typeof (c.insert) === 'string')
                    .map((c) => c.insert.replace(/\n/g, ' '));
                const jsonStrippedContent = content.join(' ');
                actual = jsonStrippedContent.trim().split(/\s+/).length;
            }
            else {
                const exceptTags = /<strong>|<\/strong>|<b>|<\/b>|<i>|<\/i>|<em>|<\/em>|<s>|<\/s>|<strike>|<\/strike>|<u>|<\/u>/gm;
                const regex = /(<([^>]+)>)/ig;
                const tagsStrippedContent = control.value.replace(exceptTags, '').replace(regex, ' ').replace('  ', ' ');
                actual = tagsStrippedContent.trim().split(/\s+/).length;
            }
            return actual < minWords ? { 'minWords': { minWords, actual } } : null;
        }
    };
};
/**
 * @description
 * Validator that requires the number of words in the editor, out of HTML tags or JSON structure, to be less than or equal
 * to the provided maximum number.
 *
 * @usageNotes
 * Validate that the editor has a maximum of 10 words:
 *
 * ```typescript
 * const editor = new FormControl('ng angular reactive forms editor wysiwyg eui ec europa npm node', euiEditorMaxWords(10));
 * console.log(editor.errors); // { maxWords: { maxWords: 10, actual: 11 } }
 * ```
 *
 * @returns A validator function that returns an error map with the
 * `maxWords` if the validation check fails, otherwise `null`.
 */
const euiEditorMaxWords = (maxWords) => {
    return (control) => {
        if (control.value) {
            let actual = 0;
            if (isJson(control.value)) {
                const content = JSON.parse(control.value).ops
                    .filter((c) => typeof (c.insert) === 'string')
                    .map((c) => c.insert.replace(/\n/g, ' '));
                const jsonStrippedContent = content.join(' ');
                actual = jsonStrippedContent.trim().split(/\s+/).length;
            }
            else {
                const regex = /(<([^>]+)>)/ig;
                const tagsStrippedContent = control.value.replace(regex, ' ');
                actual = tagsStrippedContent.trim().split(/\s+/).length;
            }
            return actual > maxWords ? { 'maxWords': { maxWords, actual } } : null;
        }
    };
};
/**
 * @description
 * Validator that requires the number of bytes in the editor, with HTML tags or JSON structure, to be greater than or equal
 * to the provided minimum number.
 *
 * @usageNotes
 * Validate that the editor has a minimum of 20 bytes:
 *
 * ```typescript
 * const editor = new FormControl('<p>europa.eu</p>', euiEditorMinBytes(20));
 * console.log(editor.errors); // { minBytes: { minBytes: 20, actual: 16 } }
 * ```
 *
 * @returns A validator function that returns an error map with the
 * `minBytes` if the validation check fails, otherwise `null`.
 */
const euiEditorMinBytes = (minBytes) => {
    return (control) => {
        if (control.value) {
            let actual = 0;
            const m = encodeURIComponent(control.value).match(/%[89ABab]/g);
            actual = control.value.length + (m ? m.length : 0);
            return actual < minBytes ? { 'minBytes': { minBytes, actual } } : null;
        }
    };
};
/**
 * @description
 * Validator that requires the number of bytes in the editor, with HTML tags or JSON structure, to be less than or equal
 * to the provided minimum number.
 *
 * @usageNotes
 * Validate that the editor has a maximum of 20 bytes:
 *
 * ```typescript
 * const editor = new FormControl('<p>europa.eu site</p>', euiEditorMinBytes(20));
 * console.log(editor.errors); // { maxBytes: { maxBytes: 20, actual: 21 } }
 * ```
 *
 * @returns A validator function that returns an error map with the
 * `maxBytes` if the validation check fails, otherwise `null`.
 */
const euiEditorMaxBytes = (maxBytes) => {
    return (control) => {
        if (control.value) {
            let actual = 0;
            if (isJson(control.value)) {
                actual = byteLength(control.value);
            }
            else {
                const m = encodeURIComponent(control.value).match(/%[89ABab]/g);
                actual = control.value.length + (m ? m.length : 0);
            }
            return actual > maxBytes ? { 'maxBytes': { maxBytes, actual } } : null;
        }
    };
};

const quillConfig = {
    suppressGlobalRegisterWarning: true,
    modules: {
        table: false,
        'better-table': {
            operationMenu: {
                items: {
                    unmergeCells: {
                        text: 'Another unmerge cells name',
                    },
                },
                color: {
                    colors: [
                        '#000000',
                        '#e60000',
                        '#ff9900',
                        '#ffff00',
                        '#008a00',
                        '#0066cc',
                        '#9933ff',
                        '#ffffff',
                        '#facccc',
                        '#ffebcc',
                        '#ffffcc',
                        '#cce8cc',
                        '#cce0f5',
                        '#ebd6ff',
                        '#bbbbbb',
                        '#f06666',
                        '#ffc266',
                        '#ffff66',
                        '#66b966',
                        '#66a3e0',
                        '#c285ff',
                        '#888888',
                        '#a10000',
                        '#b26b00',
                        '#b2b200',
                        '#006100',
                        '#0047b2',
                        '#6b24b2',
                        '#444444',
                        '#5c0000',
                        '#663d00',
                        '#666600',
                        '#003700',
                        '#002966',
                        '#3d1466',
                    ],
                    text: 'Background Colors',
                }
            }
        },
        keyboard: {
            bindings: QuillBetterTable.keyboardBindings,
        },
    },
};
class EuiEditorModule {
}
/** @nocollapse */ EuiEditorModule.ɵmod = i0.ɵɵdefineNgModule({ type: EuiEditorModule });
/** @nocollapse */ EuiEditorModule.ɵinj = i0.ɵɵdefineInjector({ factory: function EuiEditorModule_Factory(t) { return new (t || EuiEditorModule)(); }, imports: [[
            CommonModule,
            FormsModule,
            ReactiveFormsModule,
            EuiTooltipDirectiveModule,
            QuillModule.forRoot(quillConfig),
            EuiMessageBoxModule,
            EuiDialogModule,
        ]] });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(EuiEditorModule, { declarations: [EuiEditorComponent,
        EuiEditorJsonViewComponent,
        EuiEditorHtmlViewComponent,
        EuiEditorCountersComponent,
        EuiEditorImageDialogComponent,
        EuiEditorMaxlengthDirective,
        EuiEditorCustomToolbarTagDirective], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule,
        EuiTooltipDirectiveModule, i3.QuillModule, EuiMessageBoxModule,
        EuiDialogModule], exports: [EuiEditorComponent,
        EuiEditorMaxlengthDirective,
        EuiEditorCustomToolbarTagDirective,
        EuiEditorCountersComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiEditorModule, [{
        type: NgModule,
        args: [{
                imports: [
                    CommonModule,
                    FormsModule,
                    ReactiveFormsModule,
                    EuiTooltipDirectiveModule,
                    QuillModule.forRoot(quillConfig),
                    EuiMessageBoxModule,
                    EuiDialogModule,
                ],
                declarations: [
                    EuiEditorComponent,
                    EuiEditorJsonViewComponent,
                    EuiEditorHtmlViewComponent,
                    EuiEditorCountersComponent,
                    EuiEditorImageDialogComponent,
                    EuiEditorMaxlengthDirective,
                    EuiEditorCustomToolbarTagDirective,
                ],
                exports: [
                    EuiEditorComponent,
                    EuiEditorMaxlengthDirective,
                    EuiEditorCustomToolbarTagDirective,
                    EuiEditorCountersComponent,
                ],
            }]
    }], null, null); })();

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

export { EuiEditorComponent, EuiEditorCountersComponent, EuiEditorCustomToolbarTagDirective, EuiEditorMaxlengthDirective, EuiEditorModule, euiEditorMaxBytes, euiEditorMaxLength, euiEditorMaxWords, euiEditorMinBytes, euiEditorMinLength, euiEditorMinWords };
//# sourceMappingURL=eui-externals-eui-editor.js.map
