import { useState, type CSSProperties, type PointerEvent } from "react"; import { ExternalLink, RotateCw, X } from "lucide-react"; import { useTranslation } from "react-i18next"; import { isLoopbackHost } from "@/lib/network"; import { isNativeRuntime } from "@/lib/runtime"; import { parseWebLink, webPreviewRestriction } from "@/lib/web-preview"; interface WebPreviewPanelProps { url: string; desktopWidth?: number; onResizeStart?: (event: PointerEvent) => void; onClose: () => void; } export function WebPreviewPanel({ url: value, desktopWidth = 544, onResizeStart, onClose }: WebPreviewPanelProps) { const { t } = useTranslation(); const [revision, setRevision] = useState(0); const url = parseWebLink(value); const restriction = url ? webPreviewRestriction(url, new URL(window.location.href), isNativeRuntime(), "credentialless" in HTMLIFrameElement.prototype) : "invalid"; const buttonClass = "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"; return (