import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ExpressionValue } from "../../ExpressionValue";
import { ExpressionValueRenderer } from "../../ExpressionValueRenderer";
import { ExpressionPiece } from "../../ExpressionStyles";
import { GroupedBracketedDiv } from "../Logic/Grouping";
import { StringDataDefinition } from "../../../Common/Data/Definitions/StringDataDefinition";
import { NumberDataDefinition } from "../../../Common/Data/Definitions/NumberDataDefinition";
import { BaseStringExpression } from "./BaseString";
export class StringListGetStringByIndexExpression extends BaseStringExpression {
    constructor() {
        super();
        this.__type = "String List Get String By Index";
        let dd = new StringDataDefinition();
        dd.list = true;
        this.value1 = ExpressionValue.createExpressionValue(this, "value1", new NumberDataDefinition());
        this.value2 = ExpressionValue.createExpressionValue(this, "value2", dd);
    }
    render() {
        return (_jsxs(GroupedBracketedDiv, Object.assign({ issue: this.getValidationIssues()[0] }, { children: [_jsx(ExpressionPiece, { children: _jsx(ExpressionValueRenderer, { el: this.value1 }, void 0) }, void 0),
                _jsx(ExpressionPiece, { children: "th of" }, void 0),
                _jsx(ExpressionPiece, { children: _jsx(ExpressionValueRenderer, { el: this.value2 }, void 0) }, void 0)] }), void 0));
    }
    evaluate(data, testContext) {
        let value2 = this.value2.evaluate(data, testContext);
        let value1 = this.value1.evaluate(data, testContext);
        if (value1 < 0) {
            throw new Error("index can not be negative.");
        }
        return value2[value1];
    }
}
//# sourceMappingURL=StringListGetStringByIndexExpression.js.map