import React, { useState } from 'react'; import { X, Edit, Download, Share2, ZoomIn, ZoomOut, Maximize2 } from 'lucide-react'; import { resolveFileUrl } from './resolveFileUrl'; export function ImageViewer({ imageUrl, onClose, onEdit }) { const [zoom, setZoom] = useState(100); const resolvedUrl = resolveFileUrl(imageUrl); const handleDownload = async () => { try { const response = await fetch(resolvedUrl); const blob = await response.blob(); const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `homepilot-${Date.now()}.png`; document.body.appendChild(a); a.click(); document.body.removeChild(a); window.URL.revokeObjectURL(url); } catch (error) { console.error('Download failed:', error); } }; const handleShare = async () => { try { if (navigator.share) { const response = await fetch(resolvedUrl); const blob = await response.blob(); const file = new File([blob], 'image.png', { type: 'image/png' }); await navigator.share({ files: [file], title: 'Generated Image', text: 'Check out this AI-generated image!', }); } else { // Fallback: copy URL to clipboard await navigator.clipboard.writeText(resolvedUrl); alert('Image URL copied to clipboard!'); } } catch (error) { console.error('Share failed:', error); } }; const handleZoomIn = () => { setZoom((prev) => Math.min(prev + 25, 200)); }; const handleZoomOut = () => { setZoom((prev) => Math.max(prev - 25, 50)); }; const handleZoomReset = () => { setZoom(100); }; return (