{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "vital-arcs",
  "type": "registry:item",
  "title": "Vital Arcs",
  "description": "A daily summary widget: concentric arcs sweep from the corner with values at their tips, round a score disc.",
  "categories": [
    "data"
  ],
  "dependencies": [
    "@shopify/react-native-skia",
    "react-native-reanimated",
    "react-native-worklets"
  ],
  "registryDependencies": [
    "https://kinetik-ui.dev/r/kinetik-tokens.json",
    "https://kinetik-ui.dev/r/kinetik-motion.json",
    "https://kinetik-ui.dev/r/kinetik-count.json"
  ],
  "files": [
    {
      "path": "src/components/kinetik/vital-arcs.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/vital-arcs.tsx",
      "content": "import { Canvas, Path, Skia, type SkPath } from '@shopify/react-native-skia';\nimport { useEffect, useMemo, useState, type ReactNode } from 'react';\nimport {\n  StyleSheet,\n  Text,\n  View,\n  type StyleProp,\n  type ViewStyle,\n  type TextProps,\n} from 'react-native';\nimport Animated, {\n  Easing,\n  useAnimatedStyle,\n  useDerivedValue,\n  useSharedValue,\n  withDelay,\n  withSpring,\n  withTiming,\n  type SharedValue,\n} from 'react-native-reanimated';\n\nimport { useCountUp } from '../../lib/kinetik/hooks/use-count-up';\nimport { useReduceMotion } from '../../lib/kinetik/hooks/use-reduce-motion';\nimport { spring } from '../../lib/kinetik/motion/motion';\nimport { useKinetikTheme } from '../../lib/kinetik/tokens/theme';\nimport { palettes, withAlpha } from '../../lib/kinetik/tokens/tokens';\n\nexport type VitalMetric = {\n  /** Shown before the value. */\n  icon?: ReactNode;\n  value: string;\n  label: string;\n  /** A small change beside the value, e.g. \"12%\". */\n  change?: { text: string; up: boolean };\n};\n\nexport type VitalRing = {\n  /** 0–100: how far round the arc reaches. Shown in the badge at its tip. */\n  value: number;\n  /** Arc colour. Defaults to sky, green and red, outside in. */\n  color?: string;\n  /** Read out by screen readers, e.g. \"Activity\". */\n  label?: string;\n};\n\nexport type VitalArcsProps = {\n  title: string;\n  /** Up to three rows on the left. */\n  metrics: readonly VitalMetric[];\n  /** Up to three arcs, outermost first. */\n  rings: readonly VitalRing[];\n  /** The figure in the disc at the arcs' centre. */\n  score: number;\n  /** Word under the score, e.g. \"PAI\". */\n  scoreLabel: string;\n  style?: StyleProp<ViewStyle>;\n};\n\nconst HEIGHT = 204;\nconst THICK = 18;\nconst GAP = 6;\nconst DISC = 100;\n/** The arcs start pointing straight down, below the card, and sweep clockwise over the top. */\nconst START = 93;\nconst SWEEP = 200;\n/** Degrees every arc shows even at 0, so the tips clear the card's bottom edge. */\nconst BASE = 64;\n\n/**\n * A daily summary widget: a few figures on the left and, rising from the\n * corner, concentric arcs that sweep round one after another, each carrying\n * its value in a badge at the tip, around a disc whose score counts up.\n */\nexport function VitalArcs({ title, metrics, rings, score, scoreLabel, style }: VitalArcsProps) {\n  const { colors, radius, space, font, shadow } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const [width, setWidth] = useState(0);\n  const tones = [colors.sky, colors.success, colors.danger];\n  const list = rings.slice(0, 3);\n\n  // The arcs' centre sits near the bottom-right corner; narrow cards shrink them.\n  const scale = width > 0 ? Math.min(1, (width * 0.42) / 188) : 1;\n  // Low enough that every arc starts below the card's bottom edge, as if rising from it.\n  const cx = width - 50 * scale;\n  const cy = HEIGHT - 54 * scale;\n  const radii = list.map(\n    (_, i) => (DISC / 2 + GAP + THICK / 2 + (list.length - 1 - i) * (THICK + GAP)) * scale,\n  );\n\n  const disc = useSharedValue(reduced ? 1 : 0);\n  useEffect(() => {\n    disc.set(reduced ? 1 : withDelay(200, withSpring(1, spring('bouncy'))));\n  }, [score, reduced, disc]);\n  const pop = useAnimatedStyle(() => ({ transform: [{ scale: 0.6 + disc.get() * 0.4 }] }));\n\n  const summary = list\n    .map((r, i) => `${r.label ?? `Ring ${i + 1}`} ${Math.round(r.value)}`)\n    .join(', ');\n\n  return (\n    <View\n      onLayout={(e) => setWidth(e.nativeEvent.layout.width)}\n      style={[\n        styles.card,\n        {\n          backgroundColor: colors.surfaceRaised,\n          borderColor: colors.border,\n          borderRadius: radius.xl + 8,\n          boxShadow: shadow.lg,\n        },\n        style,\n      ]}\n    >\n      {width > 0 ? (\n        <View\n          accessible\n          accessibilityLabel={`${score} ${scoreLabel}. ${summary}`}\n          style={StyleSheet.absoluteFill}\n        >\n          <Canvas style={StyleSheet.absoluteFill} pointerEvents=\"none\">\n            {list.map((ring, i) => (\n              <Arc\n                key={i}\n                cx={cx}\n                cy={cy}\n                r={radii[i]!}\n                thick={THICK * scale}\n                value={ring.value}\n                order={i}\n                color={ring.color ?? tones[i]!}\n                track={withAlpha(colors.text, 0.05)}\n              />\n            ))}\n          </Canvas>\n          {list.map((ring, i) => (\n            <Badge\n              key={i}\n              cx={cx}\n              cy={cy}\n              r={radii[i]!}\n              value={ring.value}\n              order={i}\n              color={ring.color ?? tones[i]!}\n              size={Math.max(20, 26 * scale)}\n            />\n          ))}\n          <Animated.View\n            style={[\n              styles.disc,\n              {\n                width: DISC * scale,\n                height: DISC * scale,\n                borderRadius: (DISC * scale) / 2,\n                left: cx - (DISC * scale) / 2,\n                top: cy - (DISC * scale) / 2,\n                backgroundColor: colors.ember,\n                boxShadow: shadow.lg,\n              },\n              pop,\n            ]}\n          >\n            <Counted\n              value={score}\n              duration={1100}\n              format={(n) => String(Math.round(n))}\n              style={{\n                color: colors.onEmber,\n                fontSize: 34 * scale,\n                lineHeight: 38 * scale,\n                fontWeight: font.weight.semibold,\n                fontVariant: ['tabular-nums'],\n              }}\n            />\n            <Text\n              style={{\n                color: colors.onEmber,\n                fontSize: 15 * scale,\n                fontWeight: font.weight.bold,\n                letterSpacing: 0.5,\n              }}\n            >\n              {scoreLabel}\n            </Text>\n          </Animated.View>\n        </View>\n      ) : null}\n\n      <View style={{ padding: space[6], paddingRight: 0, gap: space[5], maxWidth: '55%' }}>\n        <Text\n          accessibilityRole=\"header\"\n          numberOfLines={1}\n          style={{\n            color: colors.text,\n            fontSize: font.size.xl,\n            fontWeight: font.weight.semibold,\n            letterSpacing: font.tracking.tight,\n          }}\n        >\n          {title}\n        </Text>\n        <View style={{ gap: space[4] }}>\n          {metrics.slice(0, 3).map((m, i) => (\n            <Metric key={m.label} metric={m} order={i} />\n          ))}\n        </View>\n      </View>\n    </View>\n  );\n}\n\nfunction arcPath(cx: number, cy: number, r: number): SkPath {\n  return Skia.PathBuilder.Make()\n    .addArc(Skia.XYWHRect(cx - r, cy - r, r * 2, r * 2), START, SWEEP)\n    .detach();\n}\n\n/** One arc: a faint full-length track, and the value sweeping along it. */\nfunction Arc({\n  cx,\n  cy,\n  r,\n  thick,\n  value,\n  order,\n  color,\n  track,\n}: {\n  cx: number;\n  cy: number;\n  r: number;\n  thick: number;\n  value: number;\n  order: number;\n  color: string;\n  track: string;\n}) {\n  const reduced = useReduceMotion();\n  const path = useMemo(() => arcPath(cx, cy, r), [cx, cy, r]);\n  const reach = useArcProgress(value, order, reduced);\n  const end = useDerivedValue(() => Math.max(0.001, reach.get()));\n  return (\n    <>\n      <Path path={path} style=\"stroke\" strokeWidth={thick} strokeCap=\"round\" color={track} />\n      <Path\n        path={path}\n        style=\"stroke\"\n        strokeWidth={thick}\n        strokeCap=\"round\"\n        color={color}\n        start={0}\n        end={end}\n      />\n    </>\n  );\n}\n\n/** Share of the arc filled, sweeping to `value` a beat after the arc outside it. */\nfunction useArcProgress(value: number, order: number, reduced: boolean): SharedValue<number> {\n  const share = Math.max(0, Math.min(1, value / 100));\n  const target = (BASE + share * (SWEEP - BASE)) / SWEEP;\n  const reach = useSharedValue(reduced ? target : 0);\n  useEffect(() => {\n    reach.set(\n      reduced\n        ? target\n        : withDelay(\n            order * 140,\n            withTiming(target, { duration: 1100, easing: Easing.out(Easing.cubic) }),\n          ),\n    );\n  }, [target, order, reduced, reach]);\n  return reach;\n}\n\n/** The value riding at the tip of its arc. */\nfunction Badge({\n  cx,\n  cy,\n  r,\n  value,\n  order,\n  color,\n  size,\n}: {\n  cx: number;\n  cy: number;\n  r: number;\n  value: number;\n  order: number;\n  color: string;\n  size: number;\n}) {\n  const { colors, font } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const reach = useArcProgress(value, order, reduced);\n  const style = useAnimatedStyle(() => {\n    const a = ((START + SWEEP * Math.max(0.001, reach.get())) * Math.PI) / 180;\n    return {\n      opacity: reach.get() > 0.01 ? 1 : 0,\n      transform: [\n        { translateX: cx + Math.cos(a) * r - size / 2 },\n        { translateY: cy + Math.sin(a) * r - size / 2 },\n      ],\n    };\n  });\n  return (\n    <Animated.View\n      style={[\n        styles.badge,\n        {\n          width: size,\n          height: size,\n          borderRadius: size / 2,\n          backgroundColor: color,\n          borderColor: withAlpha(colors.highlight, 0.5),\n        },\n        style,\n      ]}\n    >\n      <View\n        style={[\n          StyleSheet.absoluteFill,\n          { borderRadius: size / 2, backgroundColor: withAlpha(colors.highlight, 0.4) },\n        ]}\n      />\n      <Text\n        style={{\n          // Dark ink on the light badge, on either theme.\n          color: palettes.light.text,\n          fontSize: size * 0.42,\n          fontWeight: font.weight.bold,\n          fontVariant: ['tabular-nums'],\n        }}\n      >\n        {Math.round(value)}\n      </Text>\n    </Animated.View>\n  );\n}\n\nfunction Metric({ metric, order }: { metric: VitalMetric; order: number }) {\n  const { colors, font } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const enter = useSharedValue(reduced ? 1 : 0);\n  useEffect(() => {\n    if (!reduced) enter.set(withDelay(120 + order * 110, withSpring(1, spring('smooth'))));\n  }, [order, reduced, enter]);\n  const style = useAnimatedStyle(() => ({\n    opacity: enter.get(),\n    transform: [{ translateX: (1 - enter.get()) * -14 }],\n  }));\n  return (\n    <Animated.View\n      accessible\n      accessibilityLabel={`${metric.label}: ${metric.value}${\n        metric.change ? `, ${metric.change.up ? 'up' : 'down'} ${metric.change.text}` : ''\n      }`}\n      style={[styles.metric, style]}\n    >\n      {metric.icon ? <View style={styles.icon}>{metric.icon}</View> : null}\n      <View style={styles.grow}>\n        <View style={styles.valueRow}>\n          <Text numberOfLines={1} style={{ color: colors.text, fontSize: font.size.lg + 2 }}>\n            {metric.value}\n          </Text>\n          {metric.change ? (\n            <Text\n              style={{\n                color: metric.change.up ? colors.success : colors.danger,\n                fontSize: font.size.xs + 1,\n                fontWeight: font.weight.semibold,\n                marginLeft: 6,\n                marginTop: 2,\n              }}\n            >\n              {metric.change.text}\n              {metric.change.up ? '↑' : '↓'}\n            </Text>\n          ) : null}\n        </View>\n        <Text numberOfLines={1} style={{ color: colors.textSubtle, fontSize: font.size.sm }}>\n          {metric.label}\n        </Text>\n      </View>\n    </Animated.View>\n  );\n}\n\n/** A figure counting up, in its own component so each count re-renders only this text. */\nfunction Counted({\n  value,\n  duration,\n  format,\n  ...text\n}: TextProps & { value: number; duration: number; format: (n: number) => string }) {\n  const reduced = useReduceMotion();\n  const shown = useCountUp(value, { instant: reduced, duration });\n  return <Text {...text}>{format(shown)}</Text>;\n}\n\nconst styles = StyleSheet.create({\n  card: { height: HEIGHT, borderWidth: StyleSheet.hairlineWidth, overflow: 'hidden' },\n  disc: { position: 'absolute', alignItems: 'center', justifyContent: 'center' },\n  badge: {\n    position: 'absolute',\n    left: 0,\n    top: 0,\n    alignItems: 'center',\n    justifyContent: 'center',\n    borderWidth: 1.5,\n    overflow: 'hidden',\n  },\n  metric: { flexDirection: 'row', alignItems: 'center', gap: 12 },\n  icon: { width: 30, alignItems: 'center' },\n  grow: { flexShrink: 1 },\n  valueRow: { flexDirection: 'row', alignItems: 'flex-start' },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "component",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "data",
    "web": "live",
    "perf": {
      "budget": "The arcs are trimmed Skia paths and the badges ride them with UI-thread timings; the score counts up for about a second. Nothing animates at rest.",
      "measurements": [
        {
          "device": "Pixel 9 emulator, API 35",
          "kind": "emulator",
          "date": "2026-10-14",
          "build": "release",
          "frameMs": 18,
          "p90Ms": 29,
          "baselineMs": 17,
          "jankyPercent": 4.36,
          "atRest": "idle",
          "memoryMb": 160
        }
      ]
    },
    "a11y": {
      "reducedMotion": "Arcs, badges and the score appear at their values without sweeping or counting.",
      "screenReader": "Each row reads as one line (\"Sleep time: 7h 2m, up 12%\"), and the arcs as one summary with the score (\"16 PAI. Activity 31, Workouts 84, Rest 53\").",
      "touchTarget": "Nothing is interactive."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { VitalArcs } from '@/components/kinetik/vital-arcs';\n\n<VitalArcs\n  title=\"Today · 21 Feb\"\n  metrics={[\n    { icon: <MoonIcon />, value: '7h 2m', label: 'Sleep time', change: { text: '12%', up: true } },\n    { icon: <HeartIcon />, value: '56 bpm', label: 'Avg. heart rate' },\n  ]}\n  rings={[\n    { value: 31, label: 'Activity' },\n    { value: 84, label: 'Workouts' },\n    { value: 53, label: 'Rest' },\n  ]}\n  score={16}\n  scoreLabel=\"PAI\"\n/>;\n```\n\n## When to use\n\n- A home-screen style summary: two or three figures and up to three goals with a headline score.\n\n## When not to use\n\n- Exact comparisons between rings: the arcs read as progress, not precise values.\n- More than three goals: use Activity Rings or a chart.\n\n## Notes\n\n- Ring values run 0–100. They sweep in outside first and re-sweep whenever a value changes.\n- Default arc colours are sky, green and red, outside in; pass `color` per ring to change them.\n- The card is 204 pt tall and shrinks the arcs on narrow widths so they stay clear of the text.\n"
  },
  "docs": "Prefer `npx kinetik-ui add vital-arcs`: it installs dependencies with expo install, so versions match your Expo SDK."
}
