import { TwitterTweetEmbed } from "react-twitter-embed"; import { YoutubeUrlRegex, TweetUrlRegex, TidalRegex, SoundCloudRegex, MixCloudRegex, SpotifyRegex, TwitchRegex, AppleMusicRegex, NostrNestsRegex, WavlakeRegex, } from "Const"; import { magnetURIDecode } from "SnortUtils"; import SoundCloudEmbed from "Element/SoundCloudEmded"; import MixCloudEmbed from "Element/MixCloudEmbed"; import SpotifyEmbed from "Element/SpotifyEmbed"; import TidalEmbed from "Element/TidalEmbed"; import TwitchEmbed from "Element/TwitchEmbed"; import AppleMusicEmbed from "Element/AppleMusicEmbed"; import WavlakeEmbed from "Element/WavlakeEmbed"; import LinkPreview from "Element/LinkPreview"; import NostrLink from "Element/NostrLink"; import MagnetLink from "Element/MagnetLink"; interface HypeTextProps { link: string; depth?: number; } export default function HyperText({ link, depth }: HypeTextProps) { const a = link; try { const url = new URL(a); const youtubeId = YoutubeUrlRegex.test(a) && RegExp.$1; const tweetId = TweetUrlRegex.test(a) && RegExp.$2; const tidalId = TidalRegex.test(a) && RegExp.$1; const soundcloundId = SoundCloudRegex.test(a) && RegExp.$1; const mixcloudId = MixCloudRegex.test(a) && RegExp.$1; const isSpotifyLink = SpotifyRegex.test(a); const isTwitchLink = TwitchRegex.test(a); const isAppleMusicLink = AppleMusicRegex.test(a); const isNostrNestsLink = NostrNestsRegex.test(a); const isWavlakeLink = WavlakeRegex.test(a); if (tweetId) { return (
); } else if (youtubeId) { return (