{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "trip-glance",
  "type": "registry:item",
  "title": "Trip Glance",
  "description": "A plane flies along a line that curves down to its destination, a white trail behind and green ahead.",
  "categories": [
    "data"
  ],
  "dependencies": [
    "@shopify/react-native-skia",
    "react-native-reanimated",
    "react-native-svg",
    "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/trip-glance.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/trip-glance.tsx",
      "content": "import {\n  Canvas,\n  Circle,\n  Group,\n  LinearGradient,\n  Path,\n  rect,\n  Skia,\n  vec,\n} from '@shopify/react-native-skia';\nimport { useEffect, useMemo, useState } from 'react';\nimport {\n  StyleSheet,\n  Text,\n  View,\n  type StyleProp,\n  type TextStyle,\n  type ViewStyle,\n} from 'react-native';\nimport Animated, {\n  useAnimatedStyle,\n  useDerivedValue,\n  useSharedValue,\n  withRepeat,\n  withSpring,\n  withTiming,\n} from 'react-native-reanimated';\nimport Svg, { Path as SvgPath } from 'react-native-svg';\n\nimport { useCountUp } from '../../lib/kinetik/hooks/use-count-up';\nimport { useReduceMotion } from '../../lib/kinetik/hooks/use-reduce-motion';\nimport { easings, spring } from '../../lib/kinetik/motion/motion';\nimport { useKinetikTheme } from '../../lib/kinetik/tokens/theme';\n\nexport type TripGlanceProps = {\n  /** Trip code in the corner, e.g. \"KN81\". */\n  code: string;\n  /** Destination code at the end of the route, e.g. \"OSL\". */\n  destination: string;\n  /** Minutes still to go. */\n  minutesLeft: number;\n  /** How far along the trip is, 0–1. Changes glide the plane along the route. */\n  progress: number;\n  /** Line under the time, e.g. \"Landing early\". */\n  status?: string;\n  /** Bags in the yellow badge. Hidden when not given. */\n  bags?: number;\n  style?: StyleProp<ViewStyle>;\n};\n\n/** Plane from Tabler Icons (MIT, https://tabler.io/icons), nose right on a 24 pt grid. */\nconst PLANE = Skia.Path.MakeFromSVGString(\n  'M16 10h4a2 2 0 0 1 0 4h-4l-4 7h-3l2 -7h-4l-2 2h-3l2 -4l-2 -4h3l2 2h4l-2 -7h3z',\n)!;\nconst ROUTE_H = 44;\nconst PAD = 8;\nconst ICON = 26;\n\n/** The route's drop at `x`, both 0–1: level for the first half, then an S-curve down. */\nexport function routeDrop(x: number): number {\n  'worklet';\n  const t = Math.max(0, Math.min(1, (x - 0.46) / 0.44));\n  return t * t * (3 - 2 * t);\n}\n\n/** \"2H 56M\" as its numbers, or just the minutes under an hour. */\nexport function splitMinutes(total: number): { hours: number; minutes: number } {\n  const whole = Math.max(0, Math.round(total));\n  return { hours: Math.floor(whole / 60), minutes: whole % 60 };\n}\n\n/**\n * A trip at a glance: a plane flies along a line that curves down to the\n * destination, a white trail behind it and the way ahead in green, while the time\n * left counts down below.\n */\nexport function TripGlance({\n  code,\n  destination,\n  minutesLeft,\n  progress,\n  status,\n  bags,\n  style,\n}: TripGlanceProps) {\n  const { colors, font, radius } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const [width, setWidth] = useState(0);\n  const { hours, minutes } = splitMinutes(useCountUp(minutesLeft, { instant: reduced }));\n  const exact = splitMinutes(minutesLeft);\n\n  const big: TextStyle = {\n    color: colors.highlight,\n    fontSize: font.size.xl,\n    fontWeight: font.weight.semibold,\n    fontVariant: ['tabular-nums'],\n  };\n  const unit = { fontSize: font.size.sm, fontWeight: font.weight.medium } as const;\n\n  return (\n    <View\n      accessible\n      accessibilityRole=\"progressbar\"\n      accessibilityLabel={[\n        `${code} to ${destination}`,\n        `${exact.hours} hours ${exact.minutes} minutes left`,\n        status,\n        bags ? `${bags} ${bags === 1 ? 'bag' : 'bags'}` : null,\n      ]\n        .filter(Boolean)\n        .join('. ')}\n      accessibilityValue={{ min: 0, max: 100, now: Math.round(progress * 100) }}\n      style={[styles.card, style]}\n    >\n      <View style={styles.between}>\n        <Text style={{ color: MUTED, fontSize: font.size.xs, fontWeight: font.weight.medium }}>\n          {code}\n        </Text>\n        {bags ? (\n          <View style={[styles.badge, { borderRadius: radius.xs }]}>\n            <Svg width={12} height={12} viewBox=\"0 0 24 24\">\n              <SvgPath\n                d=\"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2h3a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h3Zm2 0h2V5h-2v2Z\"\n                fill={BADGE_INK}\n              />\n            </Svg>\n            <Text\n              style={{ color: BADGE_INK, fontSize: font.size.xs, fontWeight: font.weight.bold }}\n            >\n              {bags}\n            </Text>\n          </View>\n        ) : null}\n      </View>\n\n      <View\n        testID=\"trip-glance-route\"\n        style={styles.route}\n        onLayout={(e) => setWidth(e.nativeEvent.layout.width)}\n      >\n        {width > 0 ? <Route width={width} progress={progress} /> : null}\n      </View>\n\n      <View style={styles.foot}>\n        <View style={styles.grow}>\n          <Text style={big}>\n            {hours > 0 ? (\n              <>\n                {hours}\n                <Text style={unit}>H </Text>\n              </>\n            ) : null}\n            {minutes}\n            <Text style={unit}>M</Text>\n          </Text>\n          {status ? (\n            <Text\n              numberOfLines={1}\n              style={{ color: GREEN, fontSize: font.size.xs, fontWeight: font.weight.medium }}\n            >\n              {status}\n            </Text>\n          ) : null}\n        </View>\n        <Text style={big}>{destination}</Text>\n      </View>\n    </View>\n  );\n}\n\nfunction Route({ width, progress }: { width: number; progress: number }) {\n  const { colors } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const p = Math.max(0, Math.min(1, progress));\n  const span = width - PAD * 2;\n  const drop = ROUTE_H - PAD * 2;\n  const at = useSharedValue(reduced ? p : 0);\n\n  useEffect(() => {\n    at.set(reduced ? p : withSpring(p, spring('smooth')));\n  }, [p, reduced, at]);\n\n  const line = useMemo(() => {\n    const b = Skia.PathBuilder.Make();\n    for (let i = 0; i <= 48; i++) {\n      const x = i / 48;\n      const px = PAD + x * span;\n      const py = PAD + routeDrop(x) * drop;\n      if (i === 0) b.moveTo(px, py);\n      else b.lineTo(px, py);\n    }\n    return b.detach();\n  }, [span, drop]);\n\n  const behind = useDerivedValue(() => rect(0, 0, PAD + at.get() * span, ROUTE_H));\n  const ahead = useDerivedValue(() => {\n    const x = PAD + at.get() * span;\n    return rect(x, 0, width - x, ROUTE_H);\n  });\n  const plane = useDerivedValue(() => {\n    const u = at.get();\n    const slope = ((routeDrop(u + 0.01) - routeDrop(u - 0.01)) / 0.02) * (drop / span);\n    return [\n      { translateX: PAD + u * span },\n      { translateY: PAD + routeDrop(u) * drop },\n      { rotate: Math.atan(slope) },\n      { scale: ICON / 24 },\n      { translateX: -12 },\n      { translateY: -12 },\n    ];\n  });\n\n  return (\n    <>\n      <Canvas style={{ width, height: ROUTE_H }}>\n        <Group clip={behind}>\n          <Path path={line} style=\"stroke\" strokeWidth={3} strokeCap=\"round\">\n            <LinearGradient\n              start={vec(PAD, 0)}\n              end={vec(PAD + span * 0.34, 0)}\n              colors={[TRAIL_FADE, colors.highlight]}\n            />\n          </Path>\n        </Group>\n        <Group clip={ahead}>\n          <Path path={line} style=\"stroke\" strokeWidth={8} strokeCap=\"round\" color={GREEN_GLOW} />\n          <Path path={line} style=\"stroke\" strokeWidth={3} strokeCap=\"round\" color={GREEN} />\n        </Group>\n        <Circle cx={PAD + span} cy={PAD + drop} r={4} color={GREEN} />\n        <Group transform={plane}>\n          <Path path={PLANE} color={colors.highlight} />\n        </Group>\n      </Canvas>\n      {reduced || p >= 1 ? null : <Ripple left={PAD + span} top={PAD + drop} />}\n    </>\n  );\n}\n\n/** A soft ring opening from the destination, cheap to run because only a view moves. */\nfunction Ripple({ left, top }: { left: number; top: number }) {\n  const t = useSharedValue(0);\n  useEffect(() => {\n    t.set(withRepeat(withTiming(1, { duration: 2200, easing: easings.standard }), -1, false));\n  }, [t]);\n  const ring = useAnimatedStyle(() => ({\n    opacity: 0.55 * (1 - t.get()),\n    transform: [{ scale: 0.4 + t.get() * 1.6 }],\n  }));\n  return (\n    <Animated.View\n      pointerEvents=\"none\"\n      style={[styles.ripple, { left: left - RIPPLE / 2, top: top - RIPPLE / 2 }, ring]}\n    />\n  );\n}\n\nconst RIPPLE = 18;\nconst MUTED = 'hsl(0, 0%, 62%)';\nconst GREEN = 'hsl(145, 80%, 50%)';\nconst GREEN_GLOW = 'hsla(145, 80%, 50%, 0.18)';\nconst TRAIL_FADE = 'hsla(0, 0%, 100%, 0)';\nconst BADGE_INK = 'hsl(45, 80%, 10%)';\n\nconst styles = StyleSheet.create({\n  card: {\n    width: '100%',\n    maxWidth: 320,\n    alignSelf: 'center',\n    borderRadius: 24,\n    borderWidth: 1,\n    borderColor: 'hsla(0, 0%, 100%, 0.08)',\n    backgroundColor: 'hsl(0, 0%, 5%)',\n    padding: 16,\n  },\n  between: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },\n  badge: {\n    flexDirection: 'row',\n    alignItems: 'center',\n    gap: 4,\n    paddingHorizontal: 7,\n    paddingVertical: 3,\n    backgroundColor: 'hsl(48, 96%, 58%)',\n  },\n  route: { height: ROUTE_H, marginVertical: 4 },\n  foot: { flexDirection: 'row', alignItems: 'flex-end', gap: 12 },\n  grow: { flex: 1 },\n  ripple: {\n    position: 'absolute',\n    width: RIPPLE,\n    height: RIPPLE,\n    borderRadius: RIPPLE / 2,\n    borderWidth: 1.5,\n    borderColor: GREEN,\n  },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "component",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "data",
    "web": "live",
    "perf": {
      "budget": "The plane and trail run on one UI-thread spring when progress changes. One small view ripples at the destination until arrival.",
      "measurements": [
        {
          "device": "Huawei P20 Lite (ANE-LX1), Android 9",
          "kind": "device",
          "date": "2026-11-02",
          "build": "release",
          "frameMs": 19,
          "p90Ms": 24,
          "jankyPercent": 51.44,
          "atRest": "animating",
          "memoryMb": 130
        }
      ]
    },
    "a11y": {
      "reducedMotion": "The plane jumps to its place, the time does not count and the destination does not ripple.",
      "screenReader": "One progress bar (\"KN81 to OSL. 2 hours 56 minutes left. Landing early. 2 bags\").",
      "touchTarget": "Not interactive."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { TripGlance } from '@/components/kinetik/trip-glance';\n\n<TripGlance\n  code=\"KN81\"\n  destination=\"OSL\"\n  minutesLeft={176}\n  progress={0.34}\n  status=\"Landing early\"\n  bags={2}\n/>;\n```\n\n## When to use\n\n- A trip in progress on a home screen or a live widget.\n- Anywhere the time left matters more than the map.\n\n## When not to use\n\n- Trips with stops: one line cannot show them.\n- When progress is unknown: an estimate that jumps backwards confuses people.\n\n## Notes\n\n- `progress` and `minutesLeft` are yours to compute.\n- The plane is the Tabler Icons plane (MIT licence, via iconstack.io).\n"
  },
  "docs": "Prefer `npx kinetik-ui add trip-glance`: it installs dependencies with expo install, so versions match your Expo SDK."
}
