import type { ActivityCost, TraitBlock, TraitSegment, } from "@initiative/domain"; import { RichDescription } from "./rich-description.js"; export function PropertyLine({ label, value, }: Readonly<{ label: string; value: string | undefined; }>) { if (!value) return null; return (
{label} {value}
); } export function SectionDivider() { return (
); } function segmentKey(seg: TraitSegment): string { return seg.type === "text" ? seg.value.slice(0, 40) : seg.items.map((i) => i.label ?? i.text.slice(0, 20)).join(","); } function TraitSegments({ segments, }: Readonly<{ segments: readonly TraitSegment[] }>) { return ( <> {segments.map((seg, i) => { if (seg.type === "text") { return ( ); } return (
{seg.items.map((item) => (
{item.label != null && ( {item.label}. )}
))}
); })} ); } const ACTION_DIAMOND = "M50 2 L96 50 L50 98 L4 50 Z M48 27 L71 50 L48 73 Z"; const ACTION_DIAMOND_SOLID = "M50 2 L96 50 L50 98 L4 50 Z"; const ACTION_DIAMOND_OUTLINE = "M90 2 L136 50 L90 98 L44 50 Z M90 29 L111 50 L90 71 L69 50 Z"; const FREE_ACTION_DIAMOND = "M50 2 L96 50 L50 98 L4 50 Z M50 12 L12 50 L50 88 L88 50 Z"; const FREE_ACTION_CHEVRON = "M48 27 L71 50 L48 73 Z"; const REACTION_ARROW = "M75 15 A42 42 0 1 0 85 55 L72 55 A30 30 0 1 1 65 25 L65 40 L92 20 L65 0 L65 15 Z"; export function ActivityIcon({ activity, }: Readonly<{ activity: ActivityCost }>) { const cls = "inline-block h-[1em] align-[-0.1em]"; if (activity.unit === "free") { return ( ); } if (activity.unit === "reaction") { return ( ); } const count = activity.number; if (count === 1) { return ( ); } if (count === 2) { return ( ); } return ( ); } export function TraitEntry({ trait }: Readonly<{ trait: TraitBlock }>) { return (
{trait.name} {trait.activity ? null : "."} {trait.activity ? ( <> {" "} ) : null} {trait.frequency ? ` (${trait.frequency})` : null} {trait.trigger ? ( <> {" "} Trigger {trait.trigger} {trait.segments.length > 0 ? ( <> {" "} Effect ) : null} ) : null}
); } export function TraitSection({ entries, heading, }: Readonly<{ entries: readonly TraitBlock[] | undefined; heading?: string; }>) { if (!entries || entries.length === 0) return null; return ( <> {heading ? (

{heading}

) : null}
{entries.map((e) => ( ))}
); }