import type { ReactNode } from "react"
import { ExternalLinkIcon } from "lucide-react"
import type { Account, ItemSummary } from "@workspace/types"
/**
* A link that opens in a new tab.
*
* Inside a queue card, which is itself a link, a nested anchor is not allowed,
* so there it opens from a click instead.
*/
export function OutLink({ href, inCard = false, children }: { href: string; inCard?: boolean; children: ReactNode }) {
const className = "hover:underline inline-flex min-w-0 items-center gap-1.5"
if (inCard) {
const open = (e: React.SyntheticEvent) => {
e.preventDefault()
e.stopPropagation()
window.open(href, "_blank", "noopener,noreferrer")
}
return (
e.key === "Enter" && open(e)}>
{children}
)
}
return (
{children}
)
}
/** An account on grain, linked to its profile there. */
export function AccountLink({ account, inCard = false }: { account: Account; inCard?: boolean }) {
return (
{item.text}
const link = item.subjectLink const lines = item.text.split("\n") const subjectLine = lines.findIndex((line) => line.startsWith("Subject: ")) return (
{lines.map((line, i) => {
const image = item.source === "classifier" ? line.match(IMAGE) : null
let content: ReactNode = line
if (i === subjectLine) {
content = (
<>
Subject:{" "}