import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk"; function toStr(value: unknown): string | null { return typeof value === "string" && value.length > 0 ? value : null; } /** Strip the `url:` tag applied by urlProp() so it can back an ``. */ function unwrapUrl(value: unknown): string | null { const raw = toStr(value); return raw?.startsWith("url:") ? raw.slice(4) : raw; } /** Render the NET ISO string as a localised date-time. */ function formatNet(value: unknown): string | null { const iso = toStr(value); if (!iso) return null; const d = new Date(iso); return Number.isNaN(d.getTime()) ? iso : d.toLocaleString(); } /** * Click-detail panel for a launch-tracker entity: launch identity, NET, * status, mission, rocket, provider, pad + location, and (when the engine * item carries it) a link to the Launch Library 2 launch page. */ export function LaunchTrackerDetail({ entity }: { entity: GeoEntity }) { const props = entity.properties ?? {}; const title = toStr(props.name) ?? toStr(entity.label) ?? "Launch"; const net = formatNet(props.net); const status = toStr(props.status); const mission = toStr(props.mission); const missionType = toStr(props.missionType); const rocket = toStr(props.rocket); const rocketFamily = toStr(props.rocketFamily); const provider = toStr(props.provider); const padName = toStr(props.padName); const location = toStr(props.location); const webcastLive = props.webcastLive === true; const link = unwrapUrl(props.launchUrl); return (
{title ?
{title}
: null}
{net ? ( <>
NET
{net}
) : null} {status ? ( <>
Status
{status}
) : null} {mission ? ( <>
Mission
{mission} {missionType ? · {missionType} : null}
) : null} {rocket ? ( <>
Rocket
{rocket} {rocketFamily ? · {rocketFamily} : null}
) : null} {provider ? ( <>
Provider
{provider}
) : null} {padName ? ( <>
Pad
{padName}
) : null} {location ? ( <>
Location
{location}
) : null}
{webcastLive ? (
● Live webcast
) : null} {link ? (
Open on Launch Library 2
) : null}
); }