import { jsx as _jsx, jsxs as _jsxs } 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 React from 'react';
import { EXECUTION_PLAN_VIEW_MODE, } from '../../stores/execution-plan/ExecutionPlanState.js';
import { Multiplicity, } from '@finos/legend-graph';
import { PanelListItem, PanelDivider, Button, PanelContent, } from '@finos/legend-art';
import { ResultTypeViewer } from './ResultTypeViewer.js';
export const FunctionParametersValidationNodeViewer = observer((props) => {
    const { functionParameters, resultType, executionPlanState } = props;
    const applicationStore = executionPlanState.applicationStore;
    const showMultiplicity = (multiplicity) => {
        if (multiplicity === Multiplicity.ZERO) {
            return '[0]';
        }
        if (multiplicity === Multiplicity.ONE) {
            return '[1]';
        }
        if (multiplicity === Multiplicity.ZERO_ONE) {
            return '[0..1]';
        }
        if (multiplicity === Multiplicity.ZERO_MANY ||
            multiplicity === Multiplicity.ONE_MANY) {
            return '[*]';
        }
        if (multiplicity.upperBound === undefined) {
            return `[${multiplicity.lowerBound.toString()}.. *]`;
        }
        return `[${multiplicity.lowerBound.toString()}..${multiplicity.upperBound.toString()}]`;
    };
    return (_jsxs(PanelContent, { darkMode: !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled, children: [_jsx("div", { className: "query-builder__function-parameters-validation__container", children: _jsxs("div", { children: [_jsx(PanelListItem, { className: "query-builder__function-parameters-validation__container__item__label", children: "Variables Details" }), _jsx(PanelDivider, {}), _jsxs("table", { className: "query-builder__function-parameters-validation__container__table table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "table__cell--left", children: "Name" }), _jsx("th", { className: "table__cell--left", children: "Type" })] }) }), _jsx("tbody", { children: functionParameters.map((parameter) => (_jsx(React.Fragment, { children: _jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: parameter.name }), _jsx("td", { className: "table__cell--left", children: `${parameter.genericType?.value.rawType.name} ${showMultiplicity(parameter.multiplicity)}` })] }) }, parameter.name))) })] })] }) }), _jsx(PanelDivider, {}), _jsx(ResultTypeViewer, { resultType: resultType }), _jsx("div", { className: "query-builder__function-parameters-validation__container", children: _jsx(Button, { className: "btn--dark execution-node-viewer__unsupported-view__to-text-mode__btn", onClick: () => executionPlanState.setViewMode(EXECUTION_PLAN_VIEW_MODE.JSON), text: "View JSON" }) }), _jsx(PanelDivider, {})] }));
});
//# sourceMappingURL=FunctionParametersValidationNodeViewer.js.map