"use client"; import Image from "next/image"; import { useRouter } from "next/navigation"; import { Icon, IconName, MarkdownText, Typography } from "@/components/ui"; import styles from "./PortraitView.module.scss"; interface PortraitViewProps { id: string; title: string; imageUrl: string; result?: string | null; } export default function PortraitView({ title, imageUrl, result }: PortraitViewProps) { const router = useRouter(); const handleDownload = async () => { try { const response = await fetch(imageUrl); const blob = await response.blob(); const url = window.URL.createObjectURL(blob); const link = document.createElement("a"); link.href = url; link.download = `${title.replace(/\s+/g, "_")}.jpg`; document.body.appendChild(link); link.click(); document.body.removeChild(link); window.URL.revokeObjectURL(url); } catch { // Fallback: open in new tab if download fails window.open(imageUrl, "_blank"); } }; return (