/** * rData applet definitions — Analytics Card. */ import type { AppletDefinition, AppletLiveData } from "../../shared/applet-types"; const analyticsCard: AppletDefinition = { id: "analytics-card", label: "Analytics Card", icon: "📊", accentColor: "#6366f1", ports: [ { name: "metric-in", type: "number", direction: "input" }, { name: "delta-out", type: "number", direction: "output" }, ], renderCompact(data: AppletLiveData): string { const { snapshot } = data; const label = (snapshot.label as string) || "Metric"; const value = (snapshot.value as number) || 0; const prev = (snapshot.previous as number) || 0; const delta = prev > 0 ? Math.round(((value - prev) / prev) * 100) : 0; const deltaColor = delta >= 0 ? "#22c55e" : "#ef4444"; const arrow = delta >= 0 ? "↑" : "↓"; return `