"use strict";

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

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

class SpreadSheetEventManager extends base_event_manager_1.BaseEventManager {
    constructor(spreadsheet) {
        super(spreadsheet.getEventBus()), this.spreadsheet = spreadsheet;
    }
    getEventTypes() {
        return Array.from(spreadsheet_events_1.SPREADSHEET_EVENT_TYPES);
    }
    emitReady() {
        this.emit(spreadsheet_events_1.VTableSheetEventType.SPREADSHEET_READY, void 0);
    }
    emitDestroyed() {
        this.emit(spreadsheet_events_1.VTableSheetEventType.SPREADSHEET_DESTROYED, void 0);
    }
    emitResized(width, height) {
        this.emit(spreadsheet_events_1.VTableSheetEventType.SPREADSHEET_RESIZED, {
            width: width,
            height: height
        });
    }
    emitSheetAdded(sheetKey, sheetTitle, index) {
        const event = {
            sheetKey: sheetKey,
            sheetTitle: sheetTitle,
            index: index
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.SHEET_ADDED, event);
    }
    emitSheetRemoved(sheetKey, sheetTitle, index) {
        const event = {
            sheetKey: sheetKey,
            sheetTitle: sheetTitle,
            index: index
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.SHEET_REMOVED, event);
    }
    emitSheetRenamed(sheetKey, oldTitle, newTitle) {
        const event = {
            sheetKey: sheetKey,
            oldTitle: oldTitle,
            newTitle: newTitle
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.SHEET_RENAMED, event);
    }
    emitSheetActivated(sheetKey, sheetTitle, previousSheetKey, previousSheetTitle) {
        const event = {
            sheetKey: sheetKey,
            sheetTitle: sheetTitle,
            previousSheetKey: previousSheetKey,
            previousSheetTitle: previousSheetTitle
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.SHEET_ACTIVATED, event);
    }
    emitSheetDeactivated(sheetKey, sheetTitle) {
        const event = {
            sheetKey: sheetKey,
            sheetTitle: sheetTitle
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.SHEET_DEACTIVATED, event);
    }
    emitSheetMoved(sheetKey, fromIndex, toIndex) {
        const event = {
            sheetKey: sheetKey,
            fromIndex: fromIndex,
            toIndex: toIndex
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.SHEET_MOVED, event);
    }
    emitSheetVisibilityChanged(sheetKey, visible) {
        const event = {
            sheetKey: sheetKey,
            visible: visible
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.SHEET_VISIBILITY_CHANGED, event);
    }
    emitImportStart(fileType) {
        const event = {
            fileType: fileType
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.IMPORT_START, event);
    }
    emitImportCompleted(fileType, sheetCount) {
        const event = {
            fileType: fileType,
            sheetCount: sheetCount
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.IMPORT_COMPLETED, event);
    }
    emitImportError(fileType, error) {
        const event = {
            fileType: fileType,
            error: error
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.IMPORT_ERROR, event);
    }
    emitExportStart(fileType, allSheets) {
        const event = {
            fileType: fileType,
            allSheets: allSheets
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.EXPORT_START, event);
    }
    emitExportCompleted(fileType, allSheets, sheetCount) {
        const event = {
            fileType: fileType,
            allSheets: allSheets,
            sheetCount: sheetCount
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.EXPORT_COMPLETED, event);
    }
    emitExportError(fileType, allSheets, error) {
        const event = {
            fileType: fileType,
            allSheets: allSheets,
            error: error
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.EXPORT_ERROR, event);
    }
    emitCrossSheetReferenceUpdated(sourceSheetKey, targetSheetKeys, affectedFormulaCount) {
        const event = {
            sourceSheetKey: sourceSheetKey,
            targetSheetKeys: targetSheetKeys,
            affectedFormulaCount: affectedFormulaCount
        };
        this.emit(spreadsheet_events_1.VTableSheetEventType.CROSS_SHEET_REFERENCE_UPDATED, event);
    }
    emitCrossSheetFormulaCalculateStart() {
        this.emit(spreadsheet_events_1.VTableSheetEventType.CROSS_SHEET_FORMULA_CALCULATE_START, void 0);
    }
    emitCrossSheetFormulaCalculateEnd() {
        this.emit(spreadsheet_events_1.VTableSheetEventType.CROSS_SHEET_FORMULA_CALCULATE_END, void 0);
    }
}

exports.SpreadSheetEventManager = SpreadSheetEventManager;
//# sourceMappingURL=spreadsheet-event-manager.js.map