import { useState } from 'react' import YoutubeEmbed from 'react-youtube' import NicoViewer from '@/components/NicoViewer' import TwitterEmbed from '@/components/TwitterEmbed' import type { FC, RefObject } from 'react' import type { NiconicoMetadata, NiconicoVideoInfo, NiconicoViewerHandle, Post } from '@/types' type Props = { ref?: RefObject post: Post onLoadComplete?: (info: NiconicoVideoInfo) => void onMetadataChange?: (meta: NiconicoMetadata) => void } export default (({ ref, post, onLoadComplete, onMetadataChange }: Props) => { const url = new URL (post.url) switch (url.hostname.split ('.').slice (-2).join ('.')) { case 'nicovideo.jp': { const mVideoId = url.pathname.match (/(?<=\/watch\/)[a-zA-Z0-9]+?(?=\/|$)/) if (!(mVideoId)) break const [videoId] = mVideoId return ( ) } case 'twitter.com': case 'x.com': { const mUserId = url.pathname.match (/(?<=\/)[^\/]+?(?=\/|$|\?)/) const mStatusId = url.pathname.match (/(?<=\/status\/)\d+?(?=\/|$|\?)/) if (!(mUserId) || !(mStatusId)) break const [userId] = mUserId const [statusId] = mStatusId return } case 'youtube.com': { const videoId = url.searchParams.get ('v') if (!(videoId)) break return ( ) } } const [framed, setFramed] = useState (false) return ( <> {framed ? (