"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MissingRuleNode = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const styled_components_1 = tslib_1.__importDefault(require("styled-components"));
const StateManager_1 = require("@appglue/common/dist/Common/StateManager");
const Connector_1 = require("./Connector");
const MissingRuleNode = ({ node, ruleDefinition }) => {
    const updateCallback = () => {
        StateManager_1.StateManager.changed(node);
        StateManager_1.StateManager.changed(ruleDefinition);
    };
    const onSetExpression = () => {
        node.setupEvaluation(ruleDefinition.getInputDefinition());
        updateCallback();
    };
    const onSetResult = () => {
        node.setupResult(ruleDefinition.getInputDefinition(), ruleDefinition.getRuleResult());
        updateCallback();
    };
    if (ruleDefinition.root === node) {
        return (0, jsx_runtime_1.jsx)(RootEmptyRuleNodeRender, { onClick: onSetExpression, children: "Add Expression" });
    }
    return ((0, jsx_runtime_1.jsxs)(Wrapper, { id: node._id, children: [(0, jsx_runtime_1.jsxs)(MissingRuleNodeRender, { children: [(0, jsx_runtime_1.jsx)(MissingRuleNodeButton, { onClick: onSetResult, children: "Result" }), (0, jsx_runtime_1.jsx)(MissingRuleNodeButton, { onClick: onSetExpression, children: "Expression" })] }), (0, jsx_runtime_1.jsx)(Connector_1.Connector, { nodeid: node._id })] }));
};
exports.MissingRuleNode = MissingRuleNode;
const MissingRuleNodeRender = styled_components_1.default.div `
    padding: 8px;
    border: 1px dashed rgba(39, 41, 50, 0.3);
    border-radius: 4px;

    display: flex;

    > * {
        margin-left: 8px;

        &:first-child {
            margin-left: 0px;
        }
    }
`;
const MissingRuleNodeButton = styled_components_1.default.div `
    background: #e1e3f0;

    color: #4050a6;

    box-shadow: 0px 2px 4px -2px rgba(39, 41, 50, 0.04);
    border-radius: 4px;

    font-size: 12px;
    font-style: normal;
    font-weight: 500;
    line-height: 17px;
    letter-spacing: 0em;
    text-align: center;

    padding: 5px 12px;

    cursor: pointer;

    &:hover {
        background: linear-gradient(0deg, rgba(64, 80, 166, 0.15), rgba(64, 80, 166, 0.15)), #e1e3f0;
    }
`;
const RootEmptyRuleNodeRender = styled_components_1.default.div `
    background: linear-gradient(0deg, rgba(64, 80, 166, 0.5), rgba(64, 80, 166, 0.5)), #ffffff;
    border-radius: 4px;

    padding: 13px 20px;

    font-size: 12px;
    font-style: normal;
    font-weight: 600;
    line-height: 17px;
    letter-spacing: 0px;
    text-align: center;

    color: #ffffff;
    cursor: pointer;

    max-width: 131px;

    &:hover {
        background: linear-gradient(0deg, rgba(64, 80, 166, 0.8), rgba(64, 80, 166, 0.8)), #ffffff;
    }
`;
const Wrapper = styled_components_1.default.div `
    padding: 4px;
    position: relative;
    border: 2px solid transparent;
`;
//# sourceMappingURL=MissingRuleNode.js.map