import React, { useContext } from 'react';
import { findChildElement, getAttribute, getNumericAttribute } from '../../dom-utils';
import { CommonExamContext } from '../context/CommonExamContext';
import ResponsiveMediaContainer from './internal/ResponsiveMediaContainer';
import { videoCaptionId } from '../../ids';
import { isWhitespace } from '../../utils';
function Video({ element, renderChildNodes, className }) {
    const { resolveAttachment } = useContext(CommonExamContext);
    const src = getAttribute(element, 'src');
    const width = getNumericAttribute(element, 'width');
    const height = getNumericAttribute(element, 'height');
    const title = findChildElement(element, 'video-title');
    const children = title && renderChildNodes(title);
    const hasCaption = children != null && !children.every(isWhitespace);
    const caption = hasCaption ? children : undefined;
    const captionId = hasCaption ? videoCaptionId(element) : undefined;
    return (React.createElement(ResponsiveMediaContainer, { caption, captionId, className, width, height },
        React.createElement("video", { className: "video", preload: "metadata", controls: true, controlsList: "nodownload", disablePictureInPicture: true, "aria-describedby": captionId },
            React.createElement("source", { src: resolveAttachment(src) }))));
}
export default React.memo(Video);
//# sourceMappingURL=Video.js.map