"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatementRuleDesigner = 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 CommonStyles_1 = require("../../DesignUI/CommonStyles");
const Notification_1 = require("../../../CommonUI/BuilderUI/Notification");
const LinkingDataDialog_1 = require("../../DesignUI/LinkingDataDialog");
const DataTypePicker_1 = require("../../../CommonUI/DataTypePicker");
const ExpressionBuilder_1 = require("../../../Expressions/ExpressionBuilder");
const StateManager_1 = require("@appglue/common/dist/Common/StateManager");
const ObserveState_1 = require("../../../CommonUI/StateManagement/ObserveState");
const StatementRuleDesigner = (props) => {
    const { ruleDefinition, editContext } = props;
    return ((0, jsx_runtime_1.jsxs)(CommonStyles_1.RuleDesignerRender, { children: [(0, jsx_runtime_1.jsx)(CommonStyles_1.RuleToolbarRender, { children: (0, jsx_runtime_1.jsx)(DataTypePicker_1.DataTypePicker, { dataDef: ruleDefinition.getRuleResult(), readonly: !ruleDefinition.canChangeOutputs, width: "150px", label: "Rule Result Type:", updateCallback: (newType) => {
                        ruleDefinition.executionResult = newType;
                        StateManager_1.StateManager.propertyChanged(ruleDefinition, "executionResult");
                    } }) }), (0, jsx_runtime_1.jsx)(RuleEditorWrapper, { children: (0, jsx_runtime_1.jsx)(RuleEditorRender, { children: (0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: ruleDefinition, control: () => ((0, jsx_runtime_1.jsx)(ExpressionBuilder_1.ExpressionBuilder, { expression: ruleDefinition.expression, onUpdate: () => {
                                StateManager_1.StateManager.propertyChanged(ruleDefinition, "expression");
                            } })), properties: ["executionResult"] }) }) }), (0, jsx_runtime_1.jsx)(Notification_1.Notification, { editContext: editContext }), (0, jsx_runtime_1.jsx)(LinkingDataDialog_1.LinkingDataDialog, { editContext: editContext })] }));
};
exports.StatementRuleDesigner = StatementRuleDesigner;
const RuleEditorWrapper = styled_components_1.default.div `
    padding: 16px 24px;
    flex: 1;
`;
const RuleEditorRender = styled_components_1.default.div `
    background: #fff;
    border-radius: 4px;
    padding: 16px 24px;
    width: 800px;
    height: 100%;
`;
//# sourceMappingURL=StatementRuleDesigner.js.map