import * as React from "react" interface MetadataDisplayProps { metadata: Record } export function MetadataDisplay({ metadata }: MetadataDisplayProps) { if (!metadata || Object.keys(metadata).length === 0) { return (

Metadata

No metadata available for this event.

) } const formatKey = (key: string): string => { return key .replace(/([A-Z])/g, ' $1') // Add space before capital letters .replace(/^./, str => str.toUpperCase()) // Capitalize first letter .replace(/_/g, ' ') // Replace underscores with spaces } const formatValue = (value: unknown): string => { if (value === null || value === undefined) { return 'N/A' } if (typeof value === 'boolean') { return value ? 'Yes' : 'No' } if (typeof value === 'object') { try { return JSON.stringify(value, null, 2) } catch { return String(value) } } // Check if it's a date string if (typeof value === 'string' && value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)) { try { return new Date(value).toLocaleString() } catch { return value } } return String(value) } const isLongValue = (value: unknown): boolean => { const stringValue = formatValue(value) return stringValue.length > 50 || stringValue.includes('\n') } return (

Metadata

{Object.entries(metadata).map(([key, value]) => (
{isLongValue(value) && typeof formatValue(value) === 'string' && formatValue(value).includes('{') ? (
                  {formatValue(value)}
                
) : ( {formatValue(value)} )}
))}
) }