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 { BlankPanelContent, PlayIcon, ControlledDropdownMenu, MenuContent, MenuContentItem, CaretDownIcon, clsx, PauseCircleIcon, ExclamationTriangleIcon, PanelContent, Button, SQLIcon, Dialog, Modal, ModalBody, ModalFooter, ModalFooterButton, ModalHeader, PanelDivider, SquareIcon, CheckSquareIcon, MenuContentItemIcon, MenuContentItemLabel, ChartIcon, CsvIcon, DebugIcon, ReportIcon, CubesLoadingIndicatorIcon, CubesLoadingIndicator, InfoCircleIcon, ShareBoxIcon, } from '@finos/legend-art';
import { observer } from 'mobx-react-lite';
import { flowResult } from 'mobx';
import { extractExecutionResultValues, TDSExecutionResult, RawExecutionResult, ExecutionError, } from '@finos/legend-graph';
import { ActionAlertActionType, ActionAlertType, DEFAULT_TAB_SIZE, useApplicationStore, } from '@finos/legend-application';
import { prettyDuration } from '@finos/legend-shared';
import { useRef, useState } from 'react';
import { QueryBuilderTDSState } from '../../stores/fetch-structure/tds/QueryBuilderTDSState.js';
import { PARAMETER_SUBMIT_ACTION } from '../../stores/shared/LambdaParameterState.js';
import { QUERY_BUILDER_TEST_ID } from '../../__lib__/QueryBuilderTesting.js';
import { CODE_EDITOR_LANGUAGE } from '@finos/legend-code-editor';
import { CodeEditor } from '@finos/legend-lego/code-editor';
import { ExecutionPlanViewer } from '../execution-plan/ExecutionPlanViewer.js';
import { QueryUsageViewer } from '../QueryUsageViewer.js';
import { DocumentationLink } from '@finos/legend-lego/application';
import { QUERY_BUILDER_DOCUMENTATION_KEY } from '../../__lib__/QueryBuilderDocumentation.js';
import { QueryBuilderTDSSimpleGridResult } from './tds/QueryBuilderTDSSimpleGridResult.js';
import { getExecutedSqlFromExecutionResult } from './tds/QueryBuilderTDSResultShared.js';
import { QueryBuilderTDSGridResult } from './tds/QueryBuilderTDSGridResult.js';
import { QueryBuilderBaseInfoTooltip } from '../shared/QueryBuilderPropertyInfoTooltip.js';
import { LineageViewer } from '../lineage/LineageViewer.js';
const PERMISSION_ERRORS = [
    'permission denied',
    'invalid user id or password',
    'Incorrect username or password',
];
export const QueryBuilderExecutionErrorPanel = observer((props) => {
    const { resultState, executionError } = props;
    const queryBuilderState = resultState.queryBuilderState;
    const errorMessage = executionError instanceof Error ? executionError.message : executionError;
    const errorStackTrace = executionError instanceof ExecutionError ? executionError.stack : '';
    const isPermissionDeniedError = Boolean(PERMISSION_ERRORS.find((e) => queryBuilderState.applicationStore.notificationService
        .getErrorMessage(executionError)
        ?.toLowerCase()
        .includes(e)));
    const openCheckEntitlmentsEditor = () => {
        queryBuilderState.checkEntitlementsState.setShowCheckEntitlementsViewer(true);
    };
    const frequentlyAskedQuestionEntry = queryBuilderState.applicationStore.documentationService.getDocEntry(QUERY_BUILDER_DOCUMENTATION_KEY.FREQUENTLY_ASKED_QUESTIONS);
    const openFrequentlyAskedQuestions = () => {
        if (frequentlyAskedQuestionEntry?.url) {
            queryBuilderState.applicationStore.navigationService.navigator.visitAddress(frequentlyAskedQuestionEntry.url);
        }
    };
    return (_jsxs(_Fragment, { children: [isPermissionDeniedError && (_jsxs("div", { className: "query-builder__result__permission-error", children: [_jsx("div", { className: "query-builder__result__permission-error__header", children: "Entitlement / Authorization error - Please" }), _jsx("button", { className: "query-builder__result__permission-error__button", disabled: (queryBuilderState.isQuerySupported &&
                            queryBuilderState.fetchStructureState
                                .implementation instanceof QueryBuilderTDSState &&
                            queryBuilderState.fetchStructureState.implementation
                                .projectionColumns.length === 0) ||
                            !queryBuilderState.canBuildQuery, onClick: openCheckEntitlmentsEditor, children: "Click Here to Check Entitlements" })] })), _jsxs("div", { className: clsx('query-builder__result__execution-error', {
                    'query-builder__result__execution-error--max': !isPermissionDeniedError,
                }), children: [_jsxs("div", { className: "query-builder__result__execution-error__header", children: [_jsx("span", { style: { fontWeight: 'bold' }, children: "Error Execution Query" }), ". Please try again later or review options in application`s", ' ', _jsx("span", { style: { fontWeight: 'bold' }, onClick: openFrequentlyAskedQuestions, children: "Help" }), ' ', "menu."] }), _jsxs("div", { className: "query-builder__result__execution-error__body", children: [_jsx("div", { className: "query-builder__result__execution-error__body__entry", children: errorMessage }), resultState.executionTraceId && queryBuilderState.config && (_jsxs("div", { className: "query-builder__result__execution-error__body__entry", children: [_jsx("span", { style: { fontWeight: 'bold' }, children: " ### trace: " }), resultState.executionTraceId, " |", ' ', _jsxs("button", { className: "query-builder__result__execution-error__body__entry__btn", disabled: !queryBuilderState.config.zipkinTraceBaseURL, onClick: () => {
                                            if (queryBuilderState.config?.zipkinTraceBaseURL) {
                                                queryBuilderState.applicationStore.navigationService.navigator.visitAddress(queryBuilderState.config.zipkinTraceBaseURL +
                                                    resultState.executionTraceId);
                                            }
                                        }, children: [queryBuilderState.config.zipkinTraceBaseURL +
                                                resultState.executionTraceId, ' '] })] })), errorStackTrace && (_jsxs("div", { className: "query-builder__result__execution-error__body__entry", children: [_jsx("span", { style: { fontWeight: 'bold' }, children: "### stack trace: " }), errorStackTrace] }))] })] })] }));
});
export const QueryBuilderEmptyExecutionResultPanel = observer((props) => {
    const { queryBuilderState } = props;
    const openCheckEntitlmentsEditor = () => {
        queryBuilderState.checkEntitlementsState.setShowCheckEntitlementsViewer(true);
    };
    return (_jsxs("div", { className: "query-builder__result__empty-result-warning", children: [_jsx("div", { className: "query-builder__result__empty-result-warning__header", children: "Query returned no data" }), _jsxs("div", { className: "query-builder__result__empty-result-warning__body", children: ["If you believe the query should return data, please", _jsx("button", { className: "query-builder__result__permission-error__button", disabled: (queryBuilderState.isQuerySupported &&
                            queryBuilderState.fetchStructureState.implementation instanceof
                                QueryBuilderTDSState &&
                            queryBuilderState.fetchStructureState.implementation
                                .projectionColumns.length === 0) ||
                            !queryBuilderState.canBuildQuery, onClick: openCheckEntitlmentsEditor, children: "Click Here to Check Entitlements" }), "or See Help menu for more options"] })] }));
});
export const QueryBuilderResultValues = observer((props) => {
    const { executionResult, queryBuilderState } = props;
    if (executionResult instanceof TDSExecutionResult) {
        if (executionResult.result.rows.length === 0) {
            return (_jsx(QueryBuilderEmptyExecutionResultPanel, { queryBuilderState: queryBuilderState }));
        }
        else {
            if (queryBuilderState.config?.TEMPORARY__enableGridEnterpriseMode) {
                return (_jsx(QueryBuilderTDSGridResult, { queryBuilderState: queryBuilderState, executionResult: executionResult }));
            }
            else {
                return (_jsx(QueryBuilderTDSSimpleGridResult, { queryBuilderState: queryBuilderState, executionResult: executionResult }));
            }
        }
    }
    else if (executionResult instanceof RawExecutionResult) {
        const inputValue = executionResult.value === null
            ? 'null'
            : executionResult.value.toString();
        return (_jsx(CodeEditor, { language: CODE_EDITOR_LANGUAGE.TEXT, inputValue: inputValue, isReadOnly: true }));
    }
    return (_jsx(CodeEditor, { language: CODE_EDITOR_LANGUAGE.JSON, inputValue: JSON.stringify(extractExecutionResultValues(executionResult), null, DEFAULT_TAB_SIZE), isReadOnly: true }));
});
export const QueryBuilderResultPanel = observer((props) => {
    const { queryBuilderState } = props;
    const applicationStore = useApplicationStore();
    const resultState = queryBuilderState.resultState;
    const queryParametersState = queryBuilderState.parametersState;
    const executionResult = resultState.executionResult;
    const resultLimit = resultState.getExecutionResultLimit();
    const [showSqlModal, setShowSqlModal] = useState(false);
    const executedSql = executionResult
        ? getExecutedSqlFromExecutionResult(executionResult, true)
        : undefined;
    const fetchStructureImplementation = queryBuilderState.fetchStructureState.implementation;
    const USER_ATTESTATION_MESSAGE = 'I attest that I am aware of the sensitive data leakage risk when exporting queried data. The data I export will only be used by me.';
    const exportQueryResults = async (format) => {
        if (queryParametersState.parameterStates.length &&
            queryParametersState.parameterStates.find((param) => !queryBuilderState.milestoningState.isMilestoningParameter(param.parameter))) {
            queryParametersState.parameterValuesEditorState.open(() => flowResult(resultState.exportData(format)).catch(applicationStore.alertUnhandledError), PARAMETER_SUBMIT_ACTION.EXPORT);
        }
        else {
            await flowResult(resultState.exportData(format)).catch(applicationStore.alertUnhandledError);
        }
    };
    const confirmExport = (format) => {
        applicationStore.alertService.setActionAlertInfo({
            message: USER_ATTESTATION_MESSAGE,
            type: ActionAlertType.CAUTION,
            actions: [
                {
                    label: 'Accept',
                    type: ActionAlertActionType.PROCEED_WITH_CAUTION,
                    handler: applicationStore.guardUnhandledError(() => exportQueryResults(format)),
                },
                {
                    label: 'Decline',
                    type: ActionAlertActionType.PROCEED,
                    default: true,
                },
            ],
        });
    };
    const allValidationIssues = queryBuilderState.allValidationIssues;
    const isSupportedQueryValid = allValidationIssues.length === 0;
    const isQueryValid = !queryBuilderState.isQuerySupported || isSupportedQueryValid;
    const isQueryValidForLocalMode = isQueryValid &&
        queryBuilderState.fetchStructureState.implementation instanceof
            QueryBuilderTDSState;
    const isExtraQueryUsageOptionsConfigured = applicationStore.pluginManager
        .getApplicationPlugins()
        .flatMap((plugin) => plugin.getExtraQueryUsageConfigurations?.() ?? []).length > 0;
    const runQuery = () => {
        resultState.setSelectedCells([]);
        resultState.setExecutionError(undefined);
        resultState.pressedRunQuery.inProgress();
        if (queryParametersState.parameterStates.length &&
            queryParametersState.parameterStates.find((param) => !queryBuilderState.milestoningState.isMilestoningParameter(param.parameter))) {
            queryParametersState.parameterValuesEditorState.open(() => flowResult(resultState.runQuery()).catch(applicationStore.alertUnhandledError), PARAMETER_SUBMIT_ACTION.RUN);
        }
        else {
            flowResult(resultState.runQuery()).catch(applicationStore.alertUnhandledError);
        }
        resultState.pressedRunQuery.complete();
    };
    const cancelQuery = applicationStore.guardUnhandledError(() => flowResult(resultState.cancelQuery()));
    const generatePlan = applicationStore.guardUnhandledError(() => flowResult(resultState.generatePlan(false)));
    const generateLineage = applicationStore.guardUnhandledError(() => flowResult(resultState.generateLineage()));
    const debugPlanGeneration = applicationStore.guardUnhandledError(() => flowResult(resultState.generatePlan(true)));
    const allowSettingPreviewLimit = queryBuilderState.isQuerySupported;
    const allowSettingLocalMode = queryBuilderState.config?.TEMPORARY__enableGridEnterpriseMode;
    const copyExpression = (value) => {
        applicationStore.clipboardService
            .copyTextToClipboard(value)
            .then(() => applicationStore.notificationService.notifySuccess('SQL Query copied', undefined, 2500))
            .catch(applicationStore.alertUnhandledError);
    };
    const isRunQueryDisabled = !isQueryValid ||
        resultState.isGeneratingPlan ||
        resultState.pressedRunQuery.isInProgress;
    const getResultSetDescription = (_executionResult) => {
        const queryDuration = resultState.executionDuration
            ? prettyDuration(resultState.executionDuration, {
                ms: true,
            })
            : undefined;
        if (_executionResult instanceof TDSExecutionResult) {
            return `${_executionResult.result.rows.length} row(s)${queryDuration ? ` in ${queryDuration}` : ''}`;
        }
        if (!queryDuration) {
            return undefined;
        }
        return `query ran in ${queryDuration}`;
    };
    const resultDescription = executionResult
        ? getResultSetDescription(executionResult)
        : undefined;
    const [previewLimitValue, setPreviewLimitValue] = useState(resultState.previewLimit);
    const changePreviewLimit = (event) => {
        setPreviewLimitValue(parseInt(event.target.value, 10));
    };
    const inputRef = useRef(null);
    const getPreviewLimit = () => {
        if (isNaN(previewLimitValue) || previewLimitValue === 0) {
            setPreviewLimitValue(1);
            queryBuilderState.resultState.setPreviewLimit(1);
        }
        else {
            queryBuilderState.resultState.setPreviewLimit(previewLimitValue);
        }
        queryBuilderState.resultState.updatePreviewLimitInConfig();
    };
    const onKeyDown = (event) => {
        if (event.code === 'Enter') {
            getPreviewLimit();
            inputRef.current?.focus();
        }
        else if (event.code === 'Escape') {
            inputRef.current?.select();
        }
    };
    const toggleIsLocalModeEnabled = () => {
        resultState.setExecutionResult(undefined);
        queryBuilderState.setIsLocalModeEnabled(!queryBuilderState.isLocalModeEnabled);
    };
    const extraExportMenuContentItems = applicationStore.pluginManager
        .getApplicationPlugins()
        .flatMap((plugin) => plugin.getExtraQueryBuilderExportMenuActionConfigurations?.() ?? [])
        .map((item) => (_jsxs(MenuContentItem, { title: !item.disableFunc?.(queryBuilderState)
            ? item.title
            : (item.disableMessage ?? 'Unsupported'), disabled: item.disableFunc?.(queryBuilderState) ?? false, onClick: () => {
            item.onClick(queryBuilderState);
        }, children: [item.icon && _jsx(MenuContentItemIcon, { children: item.icon }), _jsx(MenuContentItemLabel, { children: item.label })] }, item.key)));
    const isLoading = resultState.isRunningQuery || resultState.isGeneratingPlan;
    return (_jsxs("div", { "data-testid": QUERY_BUILDER_TEST_ID.QUERY_BUILDER_RESULT_PANEL, className: "panel query-builder__result", children: [showSqlModal && executedSql && (_jsx(Dialog, { open: Boolean(showSqlModal), onClose: () => setShowSqlModal(false), children: _jsxs(Modal, { className: "editor-modal", darkMode: !applicationStore.layoutService
                        .TEMPORARY__isLightColorThemeEnabled, children: [_jsx(ModalHeader, { title: "Executed SQL Query" }), _jsx(ModalBody, { className: "query-builder__sql__modal", children: _jsxs(_Fragment, { children: [_jsx(CodeEditor, { inputValue: executedSql, isReadOnly: true, language: CODE_EDITOR_LANGUAGE.SQL, hideMinimap: true }), _jsx(PanelDivider, {})] }) }), _jsxs(ModalFooter, { children: [_jsx(ModalFooterButton, { formatText: false, onClick: () => copyExpression(executedSql), text: "Copy SQL to Clipboard" }), _jsx(ModalFooterButton, { onClick: () => setShowSqlModal(false), text: "Close", type: "secondary" })] })] }) })), _jsxs("div", { className: "panel__header", children: [_jsxs("div", { className: "panel__header__title", children: [_jsx("div", { className: "panel__header__title__label", children: "results" }), executedSql && (_jsx(Button, { onClick: () => setShowSqlModal(true), title: "Executed SQL", className: "query-builder__result__sql__actions", children: _jsx(SQLIcon, {}) })), resultState.pressedRunQuery.isInProgress && (_jsx("div", { className: "panel__header__title__label__status", children: "Running Query..." })), resultDescription && resultState.executionTraceId && (_jsx("div", { "data-testid": QUERY_BUILDER_TEST_ID.QUERY_BUILDER_RESULT_ANALYTICS, className: "query-builder__result__analytics", children: _jsx(QueryBuilderBaseInfoTooltip, { title: "Execution Result Analytics", data: [
                                        {
                                            label: 'Trace',
                                            value: 'available here',
                                            actionButton: (_jsx("div", { className: "query-builder__tooltip__item__action", children: _jsx("button", { disabled: !queryBuilderState.config?.zipkinTraceBaseURL, title: queryBuilderState.config?.zipkinTraceBaseURL
                                                        ? ''
                                                        : 'No zipkin trace URL configured', onClick: () => {
                                                        if (queryBuilderState.config?.zipkinTraceBaseURL) {
                                                            applicationStore.navigationService.navigator.visitAddress(queryBuilderState.config.zipkinTraceBaseURL +
                                                                resultState.executionTraceId);
                                                        }
                                                    }, children: _jsx(ShareBoxIcon, {}) }) })),
                                        },
                                    ], children: _jsx("div", { className: "editable-value", children: resultDescription }) }) })), resultDescription && !resultState.executionTraceId && (_jsx("div", { "data-testid": QUERY_BUILDER_TEST_ID.QUERY_BUILDER_RESULT_ANALYTICS, className: "query-builder__result__analytics", children: resultDescription })), executionResult &&
                                resultState.checkForStaleResults &&
                                !resultState.isRunningQuery && (_jsxs("div", { className: "query-builder__result__stale-status", children: [_jsx("div", { className: "query-builder__result__stale-status__icon", children: _jsx(ExclamationTriangleIcon, {}) }), _jsx("div", { className: "query-builder__result__stale-status__label", children: "Preview data might be stale" })] })), executionResult &&
                                executionResult instanceof TDSExecutionResult &&
                                resultState.isExecutionResultOverflowing && (_jsxs("div", { className: "query-builder__result__stale-status", children: [_jsx("div", { className: "query-builder__result__stale-status__icon", children: _jsx(ExclamationTriangleIcon, {}) }), _jsx("div", { className: "query-builder__result__stale-status__label", children: "Data below is not complete - query produces more rows than the set grid preview limit" }), _jsx("div", { className: "query-builder__result__stale-status__icon", title: `The preview limit is set to ${resultLimit}. The results in the grid below are being limited by this limit and running query with a higher limit would produce more rows. Export will not apply this limit.`, children: _jsx(InfoCircleIcon, {}) })] }))] }), _jsxs("div", { className: "panel__header__actions query-builder__result__header__actions", children: [resultState.exportState.isInProgress && (_jsx("div", { className: "panel__header__title__label__status", children: "Exporting..." })), allowSettingLocalMode && (_jsxs("div", { className: "query-builder__result__advanced__mode", children: [_jsxs("div", { className: "query-builder__result__advanced__mode__label", children: ["Local Mode", _jsx(DocumentationLink, { title: "The grid in local mode performs all operations like grouping, sorting, filtering, etc after initial query execution locally withought reaching out to server. This limits the number of rows to smaller number so they can fit in memory", documentationKey: QUERY_BUILDER_DOCUMENTATION_KEY.QUESTION_HOW_TO_USE_LOCAL_GRID_MODE })] }), _jsx("button", { className: clsx('query-builder__result__advanced__mode__toggler__btn', {
                                            'query-builder__result__advanced__mode__toggler__btn--toggled': queryBuilderState.isLocalModeEnabled,
                                        }), disabled: !isQueryValidForLocalMode, onClick: toggleIsLocalModeEnabled, tabIndex: -1, children: queryBuilderState.isLocalModeEnabled ? (_jsx(CheckSquareIcon, {})) : (_jsx(SquareIcon, {})) })] })), allowSettingPreviewLimit && (_jsxs("div", { className: "query-builder__result__limit", children: [_jsx("div", { className: "query-builder__result__limit__label", children: "preview row limit" }), _jsx("input", { ref: inputRef, className: "input--dark query-builder__result__limit__input", spellCheck: false, type: "number", value: previewLimitValue, onChange: changePreviewLimit, onBlur: getPreviewLimit, onKeyDown: onKeyDown, disabled: !isQueryValid })] })), _jsx("div", { className: "query-builder__result__execute-btn btn__dropdown-combo btn__dropdown-combo--primary", children: resultState.isRunningQuery ? (_jsx("button", { className: "btn__dropdown-combo__canceler query-builder__result__execute-btn__btn", onClick: cancelQuery, tabIndex: -1, disabled: !isQueryValid, children: _jsxs("div", { className: "btn--dark btn--caution btn__dropdown-combo__canceler__label query-builder__result__execute-btn__btn", children: [_jsx(PauseCircleIcon, {}), "Stop"] }) })) : (_jsxs(_Fragment, { children: [_jsxs("button", { className: "btn__dropdown-combo__label query-builder__result__execute-btn__btn query-builder__result__execute-btn__btn--green", onClick: runQuery, tabIndex: -1, title: allValidationIssues.length
                                                ? `Query is not valid:\n${allValidationIssues
                                                    .map((issue) => `\u2022 ${issue}`)
                                                    .join('\n')}`
                                                : undefined, disabled: isRunQueryDisabled, children: [_jsx(PlayIcon, {}), "Run Query"] }), _jsx(ControlledDropdownMenu, { className: "btn__dropdown-combo__dropdown-btn query-builder__result__execute-btn__btn query-builder__result__execute-btn__btn--green", disabled: isRunQueryDisabled, content: _jsxs(MenuContent, { children: [_jsxs(MenuContentItem, { className: "btn__dropdown-combo__option", onClick: generatePlan, disabled: isRunQueryDisabled, children: [_jsx(MenuContentItemIcon, { children: _jsx(ReportIcon, {}) }), _jsx(MenuContentItemLabel, { children: "Generate Plan" })] }), _jsxs(MenuContentItem, { className: "btn__dropdown-combo__option", onClick: debugPlanGeneration, disabled: isRunQueryDisabled, children: [_jsx(MenuContentItemIcon, { children: _jsx(DebugIcon, {}) }), _jsx(MenuContentItemLabel, { children: "Debug" })] }), _jsxs(MenuContentItem, { className: "btn__dropdown-combo__option", onClick: generateLineage, disabled: isRunQueryDisabled, children: [_jsx(MenuContentItemIcon, { children: _jsx(ReportIcon, {}) }), _jsx(MenuContentItemLabel, { children: "View Lineage" })] })] }), menuProps: {
                                                anchorOrigin: { vertical: 'bottom', horizontal: 'right' },
                                                transformOrigin: { vertical: 'top', horizontal: 'right' },
                                            }, children: _jsx(CaretDownIcon, {}) })] })) }), _jsxs(ControlledDropdownMenu, { className: "query-builder__result__export__dropdown", title: "Export", disabled: !isQueryValid, content: _jsxs(MenuContent, { children: [Object.values(fetchStructureImplementation.exportDataFormatOptions).map((format) => (_jsxs(MenuContentItem, { onClick: () => confirmExport(format), children: [_jsx(MenuContentItemIcon, { children: _jsx(CsvIcon, {}) }), _jsx(MenuContentItemLabel, { children: format })] }, format))), _jsxs(MenuContentItem, { onClick: () => resultState.setIsQueryUsageViewerOpened(true), disabled: queryBuilderState.changeDetectionState.hasChanged ||
                                                !isExtraQueryUsageOptionsConfigured, children: [_jsx(MenuContentItemIcon, { children: _jsx(ChartIcon, {}) }), _jsx(MenuContentItemLabel, { children: "Others..." })] }), extraExportMenuContentItems] }), menuProps: {
                                    anchorOrigin: { vertical: 'bottom', horizontal: 'right' },
                                    transformOrigin: { vertical: 'top', horizontal: 'right' },
                                    elevation: 7,
                                }, children: [_jsx("div", { className: "query-builder__result__export__dropdown__label", children: "Export" }), _jsx("div", { className: "query-builder__result__export__dropdown__trigger", children: _jsx(CaretDownIcon, {}) })] }), resultState.isQueryUsageViewerOpened && (_jsx(QueryUsageViewer, { resultState: resultState })), applicationStore.pluginManager
                                .getApplicationPlugins()
                                .flatMap((plugin) => plugin.getExtraQueryBuilderExportMenuActionConfigurations?.() ??
                                [])
                                .map((item) => (_jsx("div", { children: item.renderExtraComponent
                                    ? item.renderExtraComponent(queryBuilderState)
                                    : undefined }, item.key)))] })] }), _jsxs(PanelContent, { className: "query-builder__result__content", children: [_jsx(CubesLoadingIndicator, { isLoading: isLoading, children: _jsx(CubesLoadingIndicatorIcon, {}) }), !executionResult && !isLoading && !resultState.executionError && (_jsx(BlankPanelContent, { children: "Build or load a valid query first" })), !isLoading && resultState.executionError && (_jsx(QueryBuilderExecutionErrorPanel, { resultState: resultState, executionError: resultState.executionError })), executionResult && !isLoading && !resultState.executionError && (_jsx("div", { className: "query-builder__result__values", children: _jsx(QueryBuilderResultValues, { executionResult: executionResult, queryBuilderState: queryBuilderState }) }))] }), _jsx(ExecutionPlanViewer, { executionPlanState: resultState.executionPlanState }), _jsx(LineageViewer, { lineageState: resultState.lineageState })] }));
});
//# sourceMappingURL=QueryBuilderResultPanel.js.map