import { ApiBase } from './ApiBase';
import * as ModuleConstants from '../../Utilities/Constants/ModuleConstants';
import * as ToolPanelRedux from '../../Redux/ActionsReducers/ToolPanelRedux';
import { ToolPanelSetModuleButtons } from '../../Redux/ActionsReducers/ToolPanelRedux';
export class ToolPanelApiImpl extends ApiBase {
    getToolPanelState() {
        return this.getAdaptableState().ToolPanel;
    }
    showToolPanelPopup() {
        this.showModulePopup(ModuleConstants.ToolPanelModuleId);
    }
    openAdapTableToolPanel() {
        const agGridApi = this.getAgGridApi();
        if (agGridApi) {
            agGridApi.openToolPanel('adaptable');
        }
    }
    closeAdapTableToolPanel() {
        const agGridApi = this.getAgGridApi();
        if (agGridApi) {
            agGridApi.closeToolPanel();
        }
    }
    getCustomToolPanels() {
        return this.getToolPanelOptions().customToolPanels ?? [];
    }
    getCustomToolPanelButtons() {
        return this.getToolPanelOptions().customButtons ?? [];
    }
    getCustomToolPanelByName(name) {
        return this.getCustomToolPanels().find((customToolPanel) => customToolPanel.name === name);
    }
    setAdaptableToolPanelVisibilityMode(adaptableToolPanel, visibilityMode) {
        if (visibilityMode === 'expanded') {
            this.setExpandedToolPanelVisibility(adaptableToolPanel);
        }
        else {
            this.setCollapsedToolPanelVisibility(adaptableToolPanel);
        }
    }
    setCustomToolPanelVisibilityMode(customToolPanelName, visibilityMode) {
        if (visibilityMode === 'expanded') {
            this.setExpandedToolPanelVisibility(customToolPanelName);
        }
        else {
            this.setCollapsedToolPanelVisibility(customToolPanelName);
        }
    }
    setModuleButtons(moduleButtons) {
        this.dispatchAction(ToolPanelSetModuleButtons(moduleButtons));
    }
    getModuleButtons() {
        return this.getToolPanelState()?.ModuleButtons ?? [];
    }
    setExpandedToolPanelVisibility(toolPanelName) {
        this.dispatchAction(ToolPanelRedux.ToolPanelExpandToolPanel(toolPanelName));
    }
    setCollapsedToolPanelVisibility(toolPanelName) {
        this.dispatchAction(ToolPanelRedux.ToolPanelCollapseToolPanel(toolPanelName));
    }
}
