"use strict";

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.WorkSheetEventManager = void 0;

const spreadsheet_events_1 = require("../ts-types/spreadsheet-events"), base_event_manager_1 = require("./base-event-manager");

class WorkSheetEventManager extends base_event_manager_1.BaseEventManager {
    constructor(worksheet) {
        super(worksheet.getEventBus()), this.worksheet = worksheet;
    }
    getEventTypes() {
        return Array.from(spreadsheet_events_1.WORKSHEET_EVENT_TYPES);
    }
    on(type, callback) {
        this.eventBus.on(type, callback);
    }
    off(type, callback) {
        callback ? this.eventBus.off(type, callback) : this.eventBus.off(type);
    }
    emit(type, event) {
        this.eventBus.emit(type, event);
    }
    emitFormulaCalculateStart(formulaCount) {
        const event = {
            sheetKey: this.worksheet.sheetKey,
            formulaCount: formulaCount
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.FORMULA_CALCULATE_START, event);
    }
    emitFormulaCalculateEnd(formulaCount, duration) {
        const event = {
            sheetKey: this.worksheet.sheetKey,
            formulaCount: formulaCount,
            duration: duration
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.FORMULA_CALCULATE_END, event);
    }
    emitFormulaError(cell, formula, error) {
        const event = {
            sheetKey: this.worksheet.sheetKey,
            cell: cell,
            formula: formula,
            error: error
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.FORMULA_ERROR, event);
    }
    emitFormulaDependencyChanged() {
        const event = {
            sheetKey: this.worksheet.sheetKey
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.FORMULA_DEPENDENCY_CHANGED, event);
    }
    emitFormulaAdded(cell, formula) {
        const event = {
            sheetKey: this.worksheet.sheetKey,
            cell: cell,
            formula: formula
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.FORMULA_ADDED, event);
    }
    emitFormulaRemoved(cell, formula) {
        const event = {
            sheetKey: this.worksheet.sheetKey,
            cell: cell,
            formula: formula
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.FORMULA_REMOVED, event);
    }
    emitDataLoaded(rowCount, colCount) {
        const event = {
            sheetKey: this.worksheet.sheetKey,
            rowCount: rowCount,
            colCount: colCount
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.DATA_LOADED, event);
    }
}

exports.WorkSheetEventManager = WorkSheetEventManager;
//# sourceMappingURL=worksheet-event-manager.js.map