import React from "react"; import { motion } from "framer-motion"; import { Globe, ExternalLink } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; interface PreviewPromptDialogProps { /** * Whether the dialog is open */ isOpen: boolean; /** * The detected URL to preview */ url: string; /** * Callback when user confirms opening preview */ onConfirm: () => void; /** * Callback when user cancels */ onCancel: () => void; } /** * Dialog component that prompts the user to open a detected URL in the preview pane * * @example * openPreview(url)} * onCancel={() => setShowPrompt(false)} * /> */ export const PreviewPromptDialog: React.FC = ({ isOpen, url, onConfirm, onCancel, }) => { // Extract domain for display const getDomain = (urlString: string) => { try { const urlObj = new URL(urlString); return urlObj.hostname; } catch { return urlString; } }; const domain = getDomain(url); const isLocalhost = domain.includes('localhost') || domain.includes('127.0.0.1'); return ( !open && onCancel()}> Open Preview? A URL was detected in the terminal output. Would you like to open it in the preview pane?

{isLocalhost ? 'Local Development Server' : 'External URL'}

{url}

The preview will open in a split view on the right side of the screen.
); };