'use client'; import React from 'react'; import { useRecordMode } from './RecordModeContext'; export function RecordModeVisuals({ children }: { children: React.ReactNode }) { const { isActive, isPlaying, zoomLevel, cursorPosition, isBlurry } = useRecordMode(); const [mounted, setMounted] = React.useState(false); const [isEmbedded, setIsEmbedded] = React.useState(false); const [iframeUrl, setIframeUrl] = React.useState(null); React.useEffect(() => { // Explicit non-magical detection const embedded = window.location.search.includes('embedded=true') || window.name === 'record-mode-iframe'; setIsEmbedded(embedded); if (!embedded) { const url = new URL(window.location.href); url.searchParams.set('embedded', 'true'); setIframeUrl(url.toString()); } }, []); // Recursion Guard: If we are already in an embedded iframe, // strictly return just the children to prevent Inception. // Note: This causes a hydration mismatch remount ONLY when actually embedded (e.g. inside Directus). // Standard users and Lighthouse bots will NOT suffer a remount. if (isEmbedded) { return ( <>