import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/**
 * Copyright (c) 2020-present, Goldman Sachs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { observer } from 'mobx-react-lite';
import { Dialog, Modal, ModalHeader, ModalBody, PanelDivider, ModalFooter, ModalFooterButton, BlankPanelContent, clsx, } from '@finos/legend-art';
import { useApplicationStore } from '@finos/legend-application';
import { useState } from 'react';
export const QueryUsageViewer = observer((props) => {
    const { resultState } = props;
    const applicationStore = useApplicationStore();
    const extraQueryUsageOptions = applicationStore.pluginManager
        .getApplicationPlugins()
        .flatMap((plugin) => plugin.getExtraQueryUsageConfigurations?.() ?? []);
    const [selectedTab, setSelectedTab] = useState(extraQueryUsageOptions[0]?.title);
    const currentTabExtensionConfig = extraQueryUsageOptions.find((option) => option.title === selectedTab);
    return (_jsx(Dialog, { open: resultState.isQueryUsageViewerOpened, onClose: () => resultState.setIsQueryUsageViewerOpened(false), children: _jsxs(Modal, { className: "query-builder__usage-viewer__modal", darkMode: !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled, children: [_jsx(ModalHeader, { title: "Query Usage" }), _jsx(ModalBody, { className: "query-builder__usage-viewer__body", children: _jsxs(_Fragment, { children: [extraQueryUsageOptions.length === 0 ? (_jsx(BlankPanelContent, { children: "Query usage is not available" })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "query-builder__usage-viewer__tab__header", children: _jsx("div", { className: "query-builder__usage-viewer__tabs", children: extraQueryUsageOptions.map((config) => (_jsxs("button", { className: clsx('query-builder__usage-viewer__tab', {
                                                    'query-builder__usage-viewer__tab--active': selectedTab === config.key,
                                                }), tabIndex: -1, onClick: () => setSelectedTab(config.key), children: [config.icon !== undefined && (_jsx("div", { className: "query-builder__usage-viewer__tab__icon", children: config.icon })), _jsx("div", { className: "query-builder__usage-viewer__tab__label", children: config.title })] }, config.key))) }) }), _jsx("div", { className: "query-builder__usage-viewer__content", children: currentTabExtensionConfig?.renderer() })] })), _jsx(PanelDivider, {})] }) }), _jsx(ModalFooter, { children: _jsx(ModalFooterButton, { onClick: () => resultState.setIsQueryUsageViewerOpened(false), text: "Close", type: "secondary" }) })] }) }));
});
//# sourceMappingURL=QueryUsageViewer.js.map