import React, { useMemo, forwardRef } from 'react' import ReactPlayer from 'react-player' import { classifyUrl } from '../utils/helpers' interface VideoEmbedProcessorProps { html: string renderVideoLinksAsEmbeds: boolean className?: string } /** * Component that processes HTML content and optionally embeds video links * as ReactPlayer components when renderVideoLinksAsEmbeds is enabled */ const VideoEmbedProcessor = forwardRef(({ html, renderVideoLinksAsEmbeds, className }, ref) => { // Process HTML and extract video URLs in a single pass to keep them in sync const { processedHtml, videoUrls } = useMemo(() => { if (!renderVideoLinksAsEmbeds || !html) { return { processedHtml: html, videoUrls: [] } } // Process HTML in stages: