{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "boarding-pass",
  "type": "registry:item",
  "title": "Boarding Pass",
  "description": "A paper boarding pass with real notches: tap the barcode to scan it and the stub tears off with a stamp.",
  "categories": [
    "card"
  ],
  "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-haptics.json"
  ],
  "files": [
    {
      "path": "src/components/kinetik/boarding-pass.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/boarding-pass.tsx",
      "content": "import {\n  BlurMask,\n  Canvas,\n  DashPathEffect,\n  Group,\n  Line,\n  Path,\n  PathOp,\n  Skia,\n  vec,\n  type SkPath,\n} from '@shopify/react-native-skia';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Pressable, StyleSheet, Text, View, type StyleProp, type ViewStyle } 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';\nimport Svg, { Path as SvgPath } from 'react-native-svg';\n\nimport { useHaptic } from '../../lib/kinetik/hooks/use-haptic';\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 PassStop = {\n  /** Airport code, e.g. \"CDG\". */\n  code: string;\n  /** City above the code. */\n  city: string;\n  /** Local time under the code. */\n  time: string;\n};\n\nexport type PassDetail = { label: string; value: string };\n\nexport type BoardingPassProps = {\n  /** Name and mark at the top. Defaults to \"Kinetik Air\". */\n  brand?: string;\n  airline: string;\n  /** Flight number under the airline. */\n  flight: string;\n  /** Cabin on the right, e.g. \"Premium\". */\n  cabin?: string;\n  /** Booking reference under the cabin. */\n  booking?: string;\n  from: PassStop;\n  to: PassStop;\n  /** Flight time in the chip between the codes, e.g. \"3h 15m\". */\n  duration: string;\n  passenger: string;\n  /** Label above the passenger. Defaults to \"Passenger name\". */\n  passengerLabel?: string;\n  /** The row of small facts: departure, terminal, gate, seat. */\n  details: readonly PassDetail[];\n  /** Encoded in the barcode's pattern. Defaults to the booking and flight. */\n  code?: string;\n  /** Start already boarded: the stub torn and stamped. */\n  boarded?: boolean;\n  /** Called when the barcode is tapped and scanned. Without it the stub is not a button. */\n  onScan?: () => void;\n  /** Colour of the striped band. */\n  accent?: string;\n  /** Haptics on scan. Defaults to true. */\n  haptics?: boolean;\n  style?: StyleProp<ViewStyle>;\n};\n\nconst BAND = 56;\nconst CORNER = 20;\nconst NOTCH = 14;\nconst STUB_H = 112;\nconst STRIPE = 22;\n/** The barcode's box inside the stub. */\nconst BAR_X = 36;\nconst BAR_TOP = 26;\nconst BAR_BOTTOM = STUB_H - 22;\n\n/**\n * Plane from Tabler Icons (MIT, https://tabler.io/icons), nose right on a 24 pt grid. The small\n * icons are SVG: a Skia canvas each would be a GPU surface apiece for a few pixels.\n */\nconst PLANE = 'M16 10h4a2 2 0 0 1 0 4h-4l-4 7h-3l2 -7h-4l-2 2h-3l2 -4l-2 -4h3l2 2h4l-2 -7h3z';\nconst MARK = 'M0 0h8l8 7-8 7H0l6-7z';\n\nfunction rectPath(x: number, y: number, w: number, h: number) {\n  return Skia.PathBuilder.Make()\n    .addRect(Skia.XYWHRect(x, y, w, h))\n    .detach();\n}\nfunction roundPath(x: number, y: number, w: number, h: number, r: number) {\n  return Skia.PathBuilder.Make()\n    .addRRect(Skia.RRectXY(Skia.XYWHRect(x, y, w, h), r, r))\n    .detach();\n}\nfunction notches(w: number, y: number) {\n  return Skia.PathBuilder.Make().addCircle(0, y, NOTCH).addCircle(w, y, NOTCH).detach();\n}\n/** Rounds the corners at one end only, and bites the half circles out of the other. */\nfunction ticketPart(w: number, h: number, roundTop: boolean, top: number) {\n  const tall = roundPath(0, roundTop ? top : -CORNER * 2, w, h - top + CORNER * 2, CORNER);\n  const cut = Skia.Path.MakeFromOp(tall, rectPath(0, top, w, h - top), PathOp.Intersect) ?? tall;\n  return Skia.Path.MakeFromOp(cut, notches(w, roundTop ? h : 0), PathOp.Difference) ?? cut;\n}\n\n/** A stable bar pattern for a code: the same text always draws the same barcode. */\nexport function barcodeBars(code: string, count = 46): number[] {\n  let h = 2166136261;\n  const bars: number[] = [];\n  for (let i = 0; i < count; i++) {\n    h ^= code.charCodeAt(i % Math.max(1, code.length)) + i;\n    h = Math.imul(h, 16777619) >>> 0;\n    bars.push(1 + (h % 3));\n  }\n  return bars;\n}\n\n/**\n * A boarding pass on paper with real notches cut at the tear line. The striped\n * band slides in as the pass rises; tapping the barcode runs a scanner line\n * over it, then the stub tears a little away and takes a Boarded stamp.\n */\nexport function BoardingPass({\n  brand = 'Kinetik Air',\n  airline,\n  flight,\n  cabin,\n  booking,\n  from,\n  to,\n  duration,\n  passenger,\n  passengerLabel = 'Passenger name',\n  details,\n  code,\n  boarded = false,\n  onScan,\n  accent = 'hsl(243, 88%, 68%)',\n  haptics = true,\n  style,\n}: BoardingPassProps) {\n  const { font, space } = useKinetikTheme();\n  // A pass is paper on either theme.\n  const paper = palettes.light;\n  const reduced = useReduceMotion();\n  const haptic = useHaptic(haptics);\n  const [width, setWidth] = useState(0);\n  const [height, setHeight] = useState(0);\n  const [scanned, setScanned] = useState(boarded);\n\n  const rise = useSharedValue(reduced ? 1 : 0);\n  const slide = useSharedValue(reduced ? 1 : 0);\n  const sweep = useSharedValue(0);\n  const tear = useSharedValue(boarded ? 1 : 0);\n\n  useEffect(() => {\n    if (reduced) return;\n    rise.set(withSpring(1, spring('smooth')));\n    slide.set(withTiming(1, { duration: 1400, easing: Easing.out(Easing.cubic) }));\n  }, [reduced, rise, slide]);\n\n  const scan = () => {\n    if (scanned) return;\n    setScanned(true);\n    onScan?.();\n    if (reduced) {\n      tear.set(1);\n      haptic('success');\n      return;\n    }\n    haptic('tap');\n    sweep.set(0);\n    sweep.set(withTiming(1, { duration: 900, easing: Easing.inOut(Easing.sin) }));\n    tear.set(withDelay(820, withSpring(1, spring('bouncy'))));\n    setTimeout(() => haptic('success'), 820);\n  };\n\n  const body = useMemo(\n    () => (width > 0 && height > 0 ? ticketPart(width, height, true, BAND) : null),\n    [width, height],\n  );\n  const band = useMemo(\n    () => (width > 0 ? roundPath(0, 0, width, BAND + CORNER * 2, CORNER) : null),\n    [width],\n  );\n  const stripes = useMemo(() => {\n    const b = Skia.PathBuilder.Make();\n    if (width <= 0) return b.detach();\n    // Diagonal bars from well left of the band, so the slide never shows an edge.\n    for (let x = -STRIPE * 8; x < width + BAND; x += STRIPE) {\n      b.moveTo(x, BAND + CORNER)\n        .lineTo(x + STRIPE / 2, BAND + CORNER)\n        .lineTo(x + STRIPE / 2 + BAND + CORNER, 0)\n        .lineTo(x + BAND + CORNER, 0)\n        .close();\n    }\n    return b.detach();\n  }, [width]);\n  const drift = useDerivedValue(() => [{ translateX: (1 - slide.get()) * -STRIPE * 6 }]);\n\n  const lift = useAnimatedStyle(() => ({\n    opacity: rise.get(),\n    transform: [{ translateY: (1 - rise.get()) * 28 }],\n  }));\n\n  const ink = paper.text;\n  const muted = paper.textSubtle;\n  const label = (text: string, align: 'left' | 'right' = 'left') => (\n    <Text style={{ color: muted, fontSize: font.size.sm, textAlign: align }}>{text}</Text>\n  );\n  const rule = <View style={[styles.rule, { backgroundColor: paper.border }]} />;\n\n  return (\n    <Animated.View style={[styles.pass, style, lift]}>\n      <View\n        accessible\n        accessibilityLabel={[\n          `Boarding pass, ${brand}`,\n          `${airline} flight ${flight}${cabin ? `, ${cabin}` : ''}`,\n          `${from.city} ${from.code} ${from.time} to ${to.city} ${to.code} ${to.time}, ${duration}`,\n          `${passengerLabel} ${passenger}`,\n          details.map((d) => `${d.label} ${d.value}`).join(', '),\n        ].join('. ')}\n        onLayout={(e) => {\n          setWidth(e.nativeEvent.layout.width);\n          setHeight(e.nativeEvent.layout.height);\n        }}\n        style={{\n          paddingTop: BAND + space[5],\n          paddingHorizontal: space[5],\n          paddingBottom: space[5],\n        }}\n      >\n        {body && band ? (\n          <Canvas style={StyleSheet.absoluteFill} pointerEvents=\"none\">\n            <Group clip={band}>\n              <Path path={band} color={accent} />\n              <Group transform={drift}>\n                <Path path={stripes} color={withAlpha(paper.text, 0.86)} />\n              </Group>\n            </Group>\n            <Path path={body} color={paper.surfaceRaised} />\n          </Canvas>\n        ) : null}\n\n        <View style={[styles.row, { gap: 8 }]}>\n          <Svg width={16} height={14} viewBox=\"0 0 16 14\" pointerEvents=\"none\">\n            <SvgPath d={MARK} fill={ink} />\n          </Svg>\n          <Text style={{ color: ink, fontSize: font.size.lg, fontWeight: font.weight.bold }}>\n            {brand}\n          </Text>\n        </View>\n\n        <View style={[styles.split, { marginTop: space[4] }]}>\n          <View>\n            <View style={[styles.row, { gap: 6 }]}>\n              <View style={[styles.logo, { backgroundColor: accent }]} />\n              <Text style={{ color: ink, fontSize: font.size.md - 1 }}>{airline}</Text>\n            </View>\n            {label(flight)}\n          </View>\n          {cabin || booking ? (\n            <View style={styles.end}>\n              {cabin ? (\n                <Text style={{ color: ink, fontSize: font.size.md - 1 }}>{cabin}</Text>\n              ) : null}\n              {booking ? label(booking, 'right') : null}\n            </View>\n          ) : null}\n        </View>\n\n        {rule}\n\n        <View style={[styles.split, { alignItems: 'flex-end' }]}>\n          <View>\n            {label(from.city)}\n            <Text style={[styles.code, { color: ink }]}>{from.code}</Text>\n            <Text style={[styles.time, { color: withAlpha(paper.text, 0.4) }]}>{from.time}</Text>\n          </View>\n          <View\n            style={[\n              styles.chip,\n              { backgroundColor: withAlpha(paper.azure, 0.12), marginBottom: 28 },\n            ]}\n          >\n            <Svg width={12} height={12} viewBox=\"0 0 24 24\" pointerEvents=\"none\">\n              <SvgPath\n                d={PLANE}\n                fill=\"none\"\n                stroke={ink}\n                strokeWidth={2.2}\n                strokeLinejoin=\"round\"\n              />\n            </Svg>\n            <Text style={{ color: ink, fontSize: 11, fontWeight: font.weight.medium }}>\n              {duration}\n            </Text>\n          </View>\n          <View style={styles.end}>\n            {label(to.city, 'right')}\n            <Text style={[styles.code, { color: ink }]}>{to.code}</Text>\n            <Text style={[styles.time, { color: withAlpha(paper.text, 0.4) }]}>{to.time}</Text>\n          </View>\n        </View>\n\n        {rule}\n\n        {label(passengerLabel)}\n        <Text\n          style={{\n            color: ink,\n            fontSize: font.size.xl,\n            fontWeight: font.weight.medium,\n            marginTop: 2,\n          }}\n        >\n          {passenger}\n        </Text>\n\n        {rule}\n\n        <View style={styles.split}>\n          {details.map((d) => (\n            <View key={d.label}>\n              {label(d.label)}\n              <Text\n                style={{\n                  color: ink,\n                  fontSize: font.size.xl,\n                  fontWeight: font.weight.medium,\n                  marginTop: 2,\n                }}\n              >\n                {d.value}\n              </Text>\n            </View>\n          ))}\n        </View>\n      </View>\n\n      <Stub\n        width={width}\n        code={code ?? `${booking ?? ''}${flight}`}\n        scanned={scanned}\n        interactive={!!onScan}\n        sweep={sweep}\n        tear={tear}\n        onPress={scan}\n      />\n    </Animated.View>\n  );\n}\n\nfunction Stub({\n  width,\n  code,\n  scanned,\n  interactive,\n  sweep,\n  tear,\n  onPress,\n}: {\n  width: number;\n  code: string;\n  scanned: boolean;\n  interactive: boolean;\n  sweep: SharedValue<number>;\n  tear: SharedValue<number>;\n  onPress: () => void;\n}) {\n  const { font } = useKinetikTheme();\n  const paper = palettes.light;\n  const shape = useMemo<SkPath | null>(\n    () => (width > 0 ? ticketPart(width, STUB_H, false, 0) : null),\n    [width],\n  );\n  const bars = useMemo(() => {\n    const b = Skia.PathBuilder.Make();\n    if (width <= 0) return b.detach();\n    const pattern = barcodeBars(code);\n    const total = pattern.reduce((s, n) => s + n * 2, 0);\n    const unit = (width - BAR_X * 2) / total;\n    let x = BAR_X;\n    pattern.forEach((n, i) => {\n      // Alternate thick and thin bars for a little rhythm.\n      const w = unit * (i % 4 === 0 ? n + 0.6 : n * 0.7);\n      b.addRect(Skia.XYWHRect(x, BAR_TOP, w, BAR_BOTTOM - BAR_TOP));\n      x += unit * n * 2;\n    });\n    return b.detach();\n  }, [width, code]);\n\n  const laserY = useDerivedValue(() => {\n    const s = sweep.get();\n    const t = s < 0.5 ? s * 2 : 2 - s * 2;\n    return BAR_TOP + (BAR_BOTTOM - BAR_TOP) * t;\n  });\n  // The line itself stays put and its group moves, so the blurred glow is one cached mask.\n  const laserAt = useDerivedValue(() => [{ translateY: laserY.get() }]);\n  const laserOn = useDerivedValue(() => (sweep.get() > 0 && sweep.get() < 1 ? 1 : 0));\n\n  const torn = useAnimatedStyle(() => ({\n    transform: [{ translateY: tear.get() * 8 }, { rotate: `${tear.get() * 2.2}deg` }],\n  }));\n  const stamp = useAnimatedStyle(() => ({\n    opacity: tear.get() > 0.02 ? Math.min(1, tear.get() * 1.5) : 0,\n    transform: [{ scale: 1.6 - Math.min(1, tear.get()) * 0.6 }, { rotate: '-8deg' }],\n  }));\n\n  return (\n    <Animated.View style={[styles.stub, { transformOrigin: 'left top' }, torn]}>\n      {shape ? (\n        <Canvas style={StyleSheet.absoluteFill} pointerEvents=\"none\">\n          <Path path={shape} color={paper.surfaceRaised} />\n          <Line\n            p1={vec(NOTCH + 8, 0.5)}\n            p2={vec(width - NOTCH - 8, 0.5)}\n            color={paper.borderStrong}\n            strokeWidth={1}\n          >\n            <DashPathEffect intervals={[5, 4]} />\n          </Line>\n          <Group opacity={scanned ? 0.35 : 1}>\n            <Path path={bars} color={paper.text} />\n          </Group>\n          <Group opacity={laserOn} transform={laserAt}>\n            <Line\n              p1={vec(BAR_X - 10, 0)}\n              p2={vec(width - BAR_X + 10, 0)}\n              color={paper.danger}\n              strokeWidth={6}\n            >\n              <BlurMask blur={5} style=\"normal\" />\n            </Line>\n            <Line\n              p1={vec(BAR_X - 10, 0)}\n              p2={vec(width - BAR_X + 10, 0)}\n              color={paper.danger}\n              strokeWidth={1.5}\n            />\n          </Group>\n        </Canvas>\n      ) : null}\n      <Pressable\n        accessibilityRole={interactive ? 'button' : undefined}\n        accessibilityLabel={scanned ? 'Boarded' : 'Barcode'}\n        accessibilityHint={interactive && !scanned ? 'Scans the boarding pass' : undefined}\n        accessibilityState={interactive ? { disabled: scanned } : undefined}\n        disabled={!interactive || scanned}\n        onPress={onPress}\n        style={StyleSheet.absoluteFill}\n      />\n      <Animated.View\n        pointerEvents=\"none\"\n        style={[\n          styles.stamp,\n          { borderColor: paper.success, backgroundColor: paper.surfaceRaised },\n          stamp,\n        ]}\n      >\n        <View style={[styles.tick, { borderColor: paper.success }]} />\n        <Text\n          style={{\n            color: paper.success,\n            fontSize: font.size.sm,\n            fontWeight: font.weight.bold,\n            letterSpacing: 1.5,\n          }}\n        >\n          BOARDED\n        </Text>\n      </Animated.View>\n    </Animated.View>\n  );\n}\n\nconst styles = StyleSheet.create({\n  pass: {},\n  row: { flexDirection: 'row', alignItems: 'center' },\n  split: { flexDirection: 'row', justifyContent: 'space-between' },\n  end: { alignItems: 'flex-end' },\n  logo: { width: 14, height: 14, borderRadius: 7 },\n  rule: { height: StyleSheet.hairlineWidth, marginVertical: 14 },\n  code: { fontSize: 32, lineHeight: 36, fontWeight: '500', letterSpacing: -0.5 },\n  time: { fontSize: 28, lineHeight: 32, fontWeight: '500', letterSpacing: -0.5 },\n  chip: {\n    flexDirection: 'row',\n    alignItems: 'center',\n    gap: 4,\n    paddingHorizontal: 9,\n    height: 22,\n    borderRadius: 11,\n  },\n  stub: { height: STUB_H },\n  stamp: {\n    position: 'absolute',\n    alignSelf: 'center',\n    top: STUB_H / 2 - 18,\n    height: 36,\n    flexDirection: 'row',\n    alignItems: 'center',\n    gap: 8,\n    paddingHorizontal: 14,\n    borderRadius: 8,\n    borderWidth: 2,\n  },\n  tick: {\n    width: 12,\n    height: 6,\n    borderLeftWidth: 2.5,\n    borderBottomWidth: 2.5,\n    marginTop: -3,\n    transform: [{ rotate: '-45deg' }],\n  },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "component",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "card",
    "web": "live",
    "perf": {
      "budget": "The ticket shape is built once per size; the band slides in on arrival and the scan runs one UI-thread timing and spring. Nothing animates at rest.",
      "measurements": [
        {
          "device": "Pixel 9 emulator, API 35",
          "kind": "emulator",
          "date": "2026-10-14",
          "build": "release",
          "frameMs": 23,
          "p90Ms": 30,
          "baselineMs": 17,
          "jankyPercent": 3.14,
          "atRest": "idle",
          "memoryMb": 158,
          "notes": "Measured during scans (scanner line with a blurred glow, then the stub tearing). Frame stats put app work at about 2 ms and render-thread work at 1 ms a frame; the rest is the emulator waiting on its virtual GPU."
        }
      ]
    },
    "a11y": {
      "reducedMotion": "The pass appears in place and a scan tears and stamps the stub at once, with no scanner line.",
      "screenReader": "The pass reads as one summary (route, times, passenger, gate and seat); the barcode is a button that becomes \"Boarded\".",
      "touchTarget": "The whole stub, 112 pt tall, is the scan button."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { BoardingPass } from '@/components/kinetik/boarding-pass';\n\n<BoardingPass\n  airline=\"Northwind\"\n  flight=\"KN 1321\"\n  cabin=\"Premium\"\n  booking=\"AG7890\"\n  from={{ code: 'CDG', city: 'Paris', time: '14:30' }}\n  to={{ code: 'JFK', city: 'New York', time: '17:45' }}\n  duration=\"8h 15m\"\n  passenger=\"Olivia Bennett\"\n  details={[\n    { label: 'Gate', value: 'B12' },\n    { label: 'Seat', value: '12A' },\n  ]}\n  onScan={checkIn}\n/>;\n```\n\n## When to use\n\n- Showing a ticket, pass or booking that the user presents or checks in with.\n\n## When not to use\n\n- As a real scannable code: the barcode is a decorative pattern. Render a real barcode or QR code for gates.\n\n## Notes\n\n- The notches are cut out of the ticket shape, so the pass sits on any background.\n- The pass is paper-white on both themes. `accent` colours the striped band.\n- Without `onScan` the stub is not a button. `boarded` starts the pass already torn and stamped.\n- `barcodeBars(code)` is exported: the same code always draws the same pattern.\n"
  },
  "docs": "Prefer `npx kinetik-ui add boarding-pass`: it installs dependencies with expo install, so versions match your Expo SDK."
}
