import classNames from 'classnames';
import React, { useLayoutEffect, useRef } from 'react';
import { useExamTranslation } from '../../i18n';
import { renderAnnotations } from '../../renderAnnotations';
import { ScreenReaderOnly } from '../ScreenReaderOnly';
function SingleLineAnswer({ displayNumber, score, value, answers, children }) {
    const { t, i18n } = useExamTranslation();
    const answerRef = useRef(null);
    useLayoutEffect(() => {
        var _a, _b, _c, _d;
        if (answerRef.current) {
            renderAnnotations(answerRef.current, (_b = (_a = score === null || score === void 0 ? void 0 : score.pregrading) === null || _a === void 0 ? void 0 : _a.annotations) !== null && _b !== void 0 ? _b : [], (_d = (_c = score === null || score === void 0 ? void 0 : score.censoring) === null || _c === void 0 ? void 0 : _c.annotations) !== null && _d !== void 0 ? _d : []);
        }
    });
    return (React.createElement(React.Fragment, null,
        displayNumber && answers.length > 1 && React.createElement("sup", null, displayNumber),
        React.createElement("span", { className: classNames('text-answer text-answer--single-line', {
                'no-answer': !value
            }), "aria-description": !value ? i18n.t('examineExam.questionHasNoAnswer') : undefined },
            React.createElement(ScreenReaderOnly, null, t('screen-reader.answer-begin')),
            React.createElement("span", { className: "e-inline-block", ref: answerRef }, value),
            React.createElement(ScreenReaderOnly, null, t('screen-reader.answer-end'))),
        children));
}
export default React.memo(SingleLineAnswer);
//# sourceMappingURL=SingleLineAnswer.js.map