"use client"; import { trpc } from "~/lib/trpc/client.js"; import { formatCents } from "~/lib/format.js"; import type { SkillEntry } from "@capakraken/shared"; import { useViewportPopover } from "~/hooks/useViewportPopover.js"; interface ResourceHoverCardProps { resourceId: string; anchorEl: HTMLElement; onClose: () => void; } export function ResourceHoverCard({ resourceId, anchorEl, onClose }: ResourceHoverCardProps) { const { ref, style } = useViewportPopover({ anchor: { kind: "element", element: anchorEl }, width: 280, estimatedHeight: 320, onClose, side: "right", ignoreElements: [anchorEl], }); const { data, isLoading } = trpc.resource.getHoverCard.useQuery( { id: resourceId }, { staleTime: 60_000 }, ); const skills = (data?.skills ?? []) as unknown as SkillEntry[]; const mainSkills = skills.filter((s) => s.isMainSkill); const topSkills = skills .filter((s) => !s.isMainSkill && s.proficiency >= 4) .sort((a, b) => b.proficiency - a.proficiency) .slice(0, 6); return (