"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TreeRuleTester = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
const GreaterThan_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/GreaterThan");
const DataDefinition_1 = require("@appglue/common/dist/Common/Data/DataDefinition");
const NumberDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/NumberDataDefinition");
const StringDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/StringDataDefinition");
const XExecutableTester_1 = require("../XExecutableTester");
const TreeRuleConfiguration_1 = require("@appglue/common/dist/Rule/Tree/TreeRuleConfiguration");
const BooleanDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/BooleanDataDefinition");
const LogicData_1 = require("../../../Expressions/Testing/LogicData");
const StoryData_1 = require("../../StoryBook/StoryData");
function factory() {
    let treeRule = new TreeRuleConfiguration_1.TreeRuleConfiguration();
    let datadef = new DataDefinition_1.DataDefinition();
    let age = new NumberDataDefinition_1.NumberDataDefinition("age");
    age.allowDecimals = false;
    datadef.fields.push(age);
    datadef.fields.push(new NumberDataDefinition_1.NumberDataDefinition("income"));
    treeRule.inputData = () => {
        return datadef;
    };
    let odatadef = new StringDataDefinition_1.StringDataDefinition();
    treeRule.executionResult = odatadef;
    treeRule.root.setupEvaluation(datadef);
    let greaterThan = new GreaterThan_1.GreaterThanExpression();
    greaterThan.value1.variableName = "age";
    greaterThan.value2.value = 18;
    treeRule.root.expression.expression = greaterThan;
    treeRule.root.falseNode.setupResult(datadef, odatadef);
    treeRule.root.falseNode.expression.value = "Nonage";
    treeRule.root.trueNode.setupEvaluation(datadef);
    greaterThan = new GreaterThan_1.GreaterThanExpression();
    greaterThan.value1.variableName = "income";
    greaterThan.value2.value = 5000;
    treeRule.root.trueNode.expression.expression = greaterThan;
    treeRule.root.trueNode.falseNode.setupResult(datadef, odatadef);
    treeRule.root.trueNode.falseNode.expression.value = "Begineer";
    treeRule.root.trueNode.trueNode.setupResult(datadef, odatadef);
    treeRule.root.trueNode.trueNode.expression.value = "Senior";
    return treeRule;
}
exports.TreeRuleTester = [
    new StoryData_1.StoryNode(() => {
        return (0, jsx_runtime_1.jsx)(XExecutableTester_1.XExecutableTester, { executable: factory() });
    }, "Test UI", "Tree Rule", "Default"),
    new StoryData_1.StoryNode(() => {
        let ruleDefinition = factory();
        let datadef = new DataDefinition_1.DataDefinition();
        let age = new NumberDataDefinition_1.NumberDataDefinition("age");
        age.allowDecimals = false;
        datadef.fields.push(age);
        datadef.fields.push(new NumberDataDefinition_1.NumberDataDefinition("income"));
        datadef.fields.push(new BooleanDataDefinition_1.BooleanDataDefinition("isEmployee"));
        datadef.fields.push(new BooleanDataDefinition_1.BooleanDataDefinition("isContractor"));
        ruleDefinition.inputData = () => datadef;
        ruleDefinition.root.trueNode.trueNode.setupEvaluation(ruleDefinition.getInputDefinition());
        ruleDefinition.root.trueNode.trueNode.expression.expression = (0, LogicData_1.getIfElseSimpleRule)().expression;
        return (0, jsx_runtime_1.jsx)(XExecutableTester_1.XExecutableTester, { executable: ruleDefinition });
    }, "Test UI", "Tree Rule", "If Then"),
];
//# sourceMappingURL=XExecutableTester.Tree-stories.js.map