import ModelListModal from "../ModelListModal/ModelListModal";
import EqualToOrNull from "../../../Types/BaseDatabase/EqualToOrNull";
import WorkflowVariable from "../../../Models/DatabaseModels/WorkflowVariable";
import React from "react";
const VariableModal = (props) => {
    return (React.createElement(ModelListModal, { modalTitle: "Select a variable", query: {
            workflowId: new EqualToOrNull(props.workflowId.toString()),
        }, isSearchEnabled: true, noItemsMessage: "You do have any variables. Please add global or workflow variables.", modalDescription: "This list contains both Global and Workflow variables.", titleField: "name", descriptionField: "description", headerField: (item) => {
            let variableType = "GLOBAL VARIABLE";
            if (item.workflowId) {
                variableType = "LOCAL WORKFLOW VARIABLE";
            }
            return React.createElement("p", { className: "text-xs text-gray-400 mb-2" }, variableType);
        }, modelType: WorkflowVariable, select: {
            _id: true,
            name: true,
            description: true,
            workflowId: true,
        }, onClose: props.onClose, onSave: (variables) => {
            var _a, _b, _c;
            if ((_a = variables[0]) === null || _a === void 0 ? void 0 : _a.workflowId) {
                props.onSave(`{{local.variables.${(_b = variables[0]) === null || _b === void 0 ? void 0 : _b.name}}}`);
            }
            else {
                props.onSave(`{{global.variables.${(_c = variables[0]) === null || _c === void 0 ? void 0 : _c.name}}}`);
            }
        } }));
};
export default VariableModal;
//# sourceMappingURL=VariableModal.js.map