"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntersectionTester = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const GreaterThan_1 = require("@appglue/common/dist/Expressions/Expressions/Logic/GreaterThan");
const DataDefinition_1 = require("@appglue/common/dist/Common/Data/DataDefinition");
const BooleanDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/BooleanDataDefinition");
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 LogicData_1 = require("../../../Expressions/Testing/LogicData");
const IntersectionRuleConfiguration_1 = require("@appglue/common/dist/Rule/Intersection/IntersectionRuleConfiguration");
const StoryData_1 = require("../../StoryBook/StoryData");
const factory = () => {
    let ruleDefinition = new IntersectionRuleConfiguration_1.IntersectionRuleConfiguration();
    let inputDataDef = new DataDefinition_1.DataDefinition();
    inputDataDef.fields.push(new BooleanDataDefinition_1.BooleanDataDefinition("isMarried"));
    inputDataDef.fields.push(new NumberDataDefinition_1.NumberDataDefinition("age"));
    inputDataDef.fields.push(new NumberDataDefinition_1.NumberDataDefinition("income"));
    inputDataDef.fields.push(new BooleanDataDefinition_1.BooleanDataDefinition("isEmployee"));
    ruleDefinition.inputData = () => inputDataDef;
    ruleDefinition.setTypeResults(new StringDataDefinition_1.StringDataDefinition("name"));
    ruleDefinition.addXAxisExpression();
    if (ruleDefinition.xaxisExpressions.length !== 2) {
        throw new Error("intersection rule is not generated correctly. x axis expression is missing.");
    }
    let greaterThan = new GreaterThan_1.GreaterThanExpression();
    greaterThan.value1.variableName = "income";
    greaterThan.value2.value = 5000;
    ruleDefinition.xaxisExpressions[0].expression = greaterThan;
    ruleDefinition.xaxisExpressions[1].variableName = "isMarried";
    ruleDefinition.addYAxisExpression();
    if (ruleDefinition.yaxisExpressions.length !== 2) {
        throw new Error("intersection rule is not generated correctly. y axis expression is missing.");
    }
    greaterThan = new GreaterThan_1.GreaterThanExpression();
    greaterThan.value1.variableName = "age";
    greaterThan.value2.value = 25;
    ruleDefinition.yaxisExpressions[0].expression = greaterThan;
    ruleDefinition.yaxisExpressions[1].variableName = "isEmployee";
    ruleDefinition.results[0].resultExpression.value = "Jose Chacin";
    ruleDefinition.results[1].resultExpression.value = "Carl Hewitt";
    ruleDefinition.results[2].resultExpression.value = "Bruno Pereira";
    ruleDefinition.results[3].resultExpression.value = "Carlos";
    return ruleDefinition;
};
exports.IntersectionTester = [
    new StoryData_1.StoryNode(() => {
        let rule = factory();
        return (0, jsx_runtime_1.jsx)(XExecutableTester_1.XExecutableTester, { executable: rule });
    }, "Test UI", "Intersection", "Default"),
    new StoryData_1.StoryNode(() => {
        let rule = factory();
        rule.xaxisExpressions[1].expression = (0, LogicData_1.getIfElseSimpleRule)().expression;
        let inputDataDef = new DataDefinition_1.DataDefinition();
        inputDataDef.fields.push(new BooleanDataDefinition_1.BooleanDataDefinition("isMarried"));
        inputDataDef.fields.push(new NumberDataDefinition_1.NumberDataDefinition("age"));
        inputDataDef.fields.push(new NumberDataDefinition_1.NumberDataDefinition("income"));
        inputDataDef.fields.push(new BooleanDataDefinition_1.BooleanDataDefinition("isEmployee"));
        inputDataDef.fields.push(new BooleanDataDefinition_1.BooleanDataDefinition("isContractor"));
        rule.inputData = () => {
            return inputDataDef;
        };
        rule.yaxisExpressions[0].expression = (0, LogicData_1.getIfElseSimpleRule)().expression;
        let greaterThan = new GreaterThan_1.GreaterThanExpression();
        greaterThan.value1.variableName = "age";
        greaterThan.value2.value = 25;
        rule.yaxisExpressions[0].expression.ifBranches[0].ifExpression.elements[0].subExpression = greaterThan;
        return (0, jsx_runtime_1.jsx)(XExecutableTester_1.XExecutableTester, { executable: rule });
    }, "Test UI", "Intersection", "IfThen"),
];
//# sourceMappingURL=XExecutableTester.Intersection-stories.js.map