import * as i0 from '@angular/core';
import { Directive, Input, NgModule } from '@angular/core';
import { DomHandler } from 'primeng/dom';
import { CommonModule } from '@angular/common';

// TODO: O que é esta diretiva?
class EditableOverlayDirective {
    table;
    ngAfterViewInit() {
        this.table.bindDocumentEditListener = this._bindDocument.bind(this);
    }
    isFromOverlayTrigger(event) {
        return event.path.some((path) => path.className && path.className.includes('ng-trigger-overlayAnimation'));
    }
    isFromModal(event) {
        return event.path.some((path) => path.className && path.className.includes('s-lookup'));
    }
    _bindDocument() {
        if (!this.table.documentEditListener) {
            this.table.documentEditListener = (event) => {
                if (!this.isFromOverlayTrigger(event) &&
                    !this.isFromModal(event) &&
                    this.table.editingCell &&
                    !this.table.editingCellClick &&
                    this.table.isEditingCellValid()) {
                    DomHandler.removeClass(this.table.editingCell, 'ui-editing-cell');
                    this.table.editingCell = null;
                    this.table.unbindDocumentEditListener();
                }
                this.table.editingCellClick = false;
            };
            document.addEventListener('click', this.table.documentEditListener);
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: EditableOverlayDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
    static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: EditableOverlayDirective, selector: "p-table[sEditableOverlay]", inputs: { table: "table" }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: EditableOverlayDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: 'p-table[sEditableOverlay]',
                }]
        }], propDecorators: { table: [{
                type: Input
            }] } });

class EditableOverlayModule {
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: EditableOverlayModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
    static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: EditableOverlayModule, declarations: [EditableOverlayDirective], imports: [CommonModule], exports: [EditableOverlayDirective] });
    static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: EditableOverlayModule, imports: [CommonModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: EditableOverlayModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommonModule],
                    declarations: [EditableOverlayDirective],
                    exports: [EditableOverlayDirective],
                }]
        }] });

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

export { EditableOverlayDirective, EditableOverlayModule };
//# sourceMappingURL=seniorsistemas-angular-components-editable-overlay.mjs.map
