import React, { useContext } from 'react';
import { QuestionContext } from '../context/QuestionContext';
import { findChildElement, getAttribute, getNumericAttribute } from '../../dom-utils';
import { Score } from '../shared/Score';
import AnswerGradingInstruction from './AnswerGradingInstruction';
import AnswerLengthInfo from '../shared/AnswerLengthInfo';
const AutogradedAnswer = ({ element, renderChildNodes, renderComponentOverrides }) => {
    const { answers } = useContext(QuestionContext);
    const gradingInstructions = findChildElement(element, 'answer-grading-instruction');
    const maxLength = getNumericAttribute(element, 'max-length');
    const content = (React.createElement(React.Fragment, null,
        maxLength != null && React.createElement(AnswerLengthInfo, { maxLength }),
        React.createElement("ul", null, renderChildNodes(element)),
        gradingInstructions && (React.createElement(AnswerGradingInstruction, { element: gradingInstructions, renderChildNodes, renderComponentOverrides }))));
    if (answers.length === 1) {
        return content;
    }
    else {
        const displayNumber = getAttribute(element, 'display-number');
        const maxScore = getNumericAttribute(element, 'max-score');
        const hint = findChildElement(element, 'hint');
        return (React.createElement("div", { className: "e-mrg-l-8" },
            React.createElement("p", { className: "exam-question-title" },
                React.createElement("span", { className: "exam-question-title__display-number--indented e-semibold" },
                    displayNumber,
                    " "),
                hint && renderChildNodes(hint),
                " ",
                React.createElement(Score, { score: maxScore })),
            content));
    }
};
export default AutogradedAnswer;
//# sourceMappingURL=AutogradedAnswer.js.map