import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { BaseTestResultData, BaseTestResultItem } from "../../Common/Testing/TestResultData";
import { TestResultDataType } from "../../Common/Testing/TestResultDataType";
import { TestContext } from "../../Tester/TestContext";
import { XTextMergeDesigner } from "./XTextMergeDesigner";
import { XTextMergeEditContext } from "./XTextMergeEditContext";
const RenderTestResult = ({ definition }) => {
    const testContext = React.useContext(TestContext);
    const resultitem = testContext === null || testContext === void 0 ? void 0 : testContext.findItem(definition._id);
    if (!resultitem) {
        return _jsx(_Fragment, {}, void 0);
    }
    return (_jsx("div", { children: _jsx("div", { dangerouslySetInnerHTML: {
                __html: resultitem.result || "",
            } }, void 0) }, void 0));
};
export class TextMergeTestResult extends BaseTestResultData {
    constructor() {
        super(...arguments);
        this.isShowResult = false;
        this.type = TestResultDataType.TEXT_MERGE;
    }
    set definition(definition) {
        this._definition = definition;
        if (this._definition) {
            this.editContext = new XTextMergeEditContext(this._definition);
            this.getTabs = () => {
                var _a;
                return [
                    {
                        name: "results",
                        ui: _jsx(RenderTestResult, { definition: this._definition }, void 0),
                    },
                    {
                        name: "merge text detail",
                        ui: (_a = this.render()) !== null && _a !== void 0 ? _a : _jsx(_Fragment, {}, void 0),
                    },
                ];
            };
        }
    }
    get definition() {
        return this._definition;
    }
    render() {
        return this.definition && this.editContext ? (_jsx(XTextMergeDesigner, { definition: this.definition, editContext: this.editContext }, void 0)) : undefined;
    }
}
export class TextMergeValueTestResult extends BaseTestResultItem {
    constructor() {
        super(...arguments);
        this.type = TestResultDataType.TEXT_MERGE_VALUE;
    }
}
//# sourceMappingURL=TextMergeTestResult.js.map