{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "roster-grant",
  "title": "Roster Grant",
  "description": "Access granted animation: a cursor clicks a CTA and team avatars switch on. Three rows of roster cards stream past a call to action, a pointer walks in and clicks it, and the monograms start turning to the accent one every seven frames — top row, middle, bottom, top, bottom, middle, so it reads as a system granting rather than a list iterating. The camera and the middle row's clearance around the pill settle on the same measured exponential; the outer rows deliberately do not, which is what stops the two sides ever looking symmetric.",
  "dependencies": [
    "remotion",
    "@remotion/google-fonts"
  ],
  "registryDependencies": [
    "https://snapcn.dev/r/snap-cn-ui.json"
  ],
  "files": [
    {
      "path": "registry/snap-cn/roster-grant/index.tsx",
      "content": "// Roster Grant · snapcn — https://snapcn.dev/docs/scenes/roster-grant\n\"use client\";\n\nimport { loadFont as loadSans } from \"@remotion/google-fonts/Inter\";\nimport { type CSSProperties, forwardRef, type ReactNode, useMemo } from \"react\";\nimport {\n  AbsoluteFill,\n  getRemotionEnvironment,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\nimport {\n  Item,\n  mixOklch,\n  parseColor,\n  resolveFont,\n  type SnapCnTheme,\n  useSnapCnTheme,\n  withAlpha,\n} from \"@/lib/snap-cn-ui\";\n\n/**\n * Three rows of roster cards drifting past a pill, a pointer that clicks it,\n * and then the roster lighting up one card at a time.\n *\n * It is the \"and everyone gets it\" shot: the outer rows stream in opposite\n * directions, the middle row parts around a single call to action, a pointer\n * walks in and presses it, the pill flips to the accent, and a beat later the\n * monograms start turning over — not left to right but sprinkled, one every\n * seven frames, so it reads as a system granting rather than a list iterating.\n *\n * Beat by beat, measured off the reference at 30fps:\n *\n * | beat | seconds | what moves |\n * | --- | --- | --- |\n * | settle | 0 – 3.0 | camera 1.184 → 1, the middle row closing on the pill |\n * | approach | 0 – 1.32 | pointer (123, 90) → (104, −3) |\n * | press | 1.62 – 2.33 | pill 1 → 0.931 → 1 |\n * | flip | 1.69 | pill goes accent, on one frame |\n * | leave | 2.05 – 3.1 | pointer out to (178, 79) |\n * | grant | 2.333 + n/30 × 7 | one monogram per step |\n * | push | 3.0 – 4.0 | the whole scene pans left, accelerating |\n *\n * The camera and the middle row settle on the **same shape** — a plain\n * `exp(-t / τ)`, no knots — and on nearly the same clock: τ = 0.75 for the\n * pull-back, 0.80 and 0.91 for the gap the middle row leaves either side of the\n * pill. Near enough that the two read as one settle; far enough that forcing\n * them onto one number leaves a card 5px wide through the first half second.\n *\n * The outer rows do **not** run off that clock, and that is the whole texture\n * of the shot. Row 1 covers 372px in four seconds and row 3 covers 355, but row\n * 3 spends a quarter of its travel in the first 0.3s and row 1 does not — so\n * the two are never symmetric about the pill and the frame never reads as a\n * pattern. Fitting both to a shared exponential was tried; it came out 10px\n * wrong through the middle of the shot, which is a third of a card gap, and the\n * rows visibly locked into step. They are measured knots because they are not a\n * formula.\n */\n\nconst { fontFamily: SANS } = loadSans(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\n\n/* ─────────────────────────────────────────────────────────────────────────\n   Geometry, in the reference's own 712×398 pixels\n   ───────────────────────────────────────────────────────────────────────── */\n\nexport const REF_W = 712;\nexport const REF_H = 398;\n\n/**\n * What the pull-back scales about, and what every content coordinate below is\n * measured from.\n *\n * Horizontally it is where the pill's centre sits for the first fifty frames of\n * the reference without moving a pixel — 356, the middle of the frame. It is\n * the camera's fixed point by measurement, not by assumption.\n */\nexport const ORIGIN = { x: 356, y: 200 };\n\n/** Row centre to row centre, at scale 1. */\nexport const ROW_PITCH = 109.5;\n\n/**\n * A card, at scale 1.\n *\n * Fixed width, left-aligned content — worth stating because the reference only\n * makes it obvious once: its longest name ends 134px short of the card's right\n * edge. Content-sized chips would have made the rows ragged and the pitch\n * unmeasurable, and the pitch is what the whole marquee is fitted to.\n */\nexport const CARD = { w: 286, h: 76, radius: 8, gap: 26 };\nexport const CARD_PITCH = CARD.w + CARD.gap;\n\n/** Inside a card. */\nexport const AVATAR = { size: 48, padX: 17.5, initials: 24 };\nexport const TEXT_X = AVATAR.padX + AVATAR.size + 12;\n/** Line boxes at `lineHeight: 1`, offset from the card's top edge. */\nexport const NAME = { size: 20, top: 16.7, weight: 500 };\nexport const ROLE = { size: 13, top: 43.3, weight: 400 };\n\n/** The pill. Content-sized: the padding is measured, the width follows the label. */\nexport const PILL = {\n  h: 43,\n  radius: 8,\n  padX: 43,\n  label: 20,\n  /** The reference sets \"Give access\" with a double word space. */\n  wordSpacing: 5,\n  iconGap: 22,\n  iconW: 24,\n  iconH: 20,\n};\n\n/**\n * The pointer — lucide's `MousePointer2`, and where its tip sits in that icon's\n * own 24×24 box.\n *\n * 22, not the reference's 14: the reference draws a plain disc, and an arrow of\n * the same *height* reads smaller because most of its box is empty. 22 puts the\n * arrow's ink at about the disc's weight.\n */\nexport const CURSOR = { size: 22, tip: { x: 4.04, y: 4.69 } };\n\n/* ─────────────────────────────────────────────────────────────────────────\n   Curves — every number below was read off the reference's own frames\n   ───────────────────────────────────────────────────────────────────────── */\n\n/** The camera's clock. The middle row settles on the same shape a shade slower. */\nexport const TAU = 0.753;\nexport const ZOOM = 0.184;\n\nexport function ease(t: number): number {\n  return Math.exp(-Math.max(0, t) / TAU);\n}\n\n/**\n * The camera, as a multiple of the settled scale.\n *\n * 1.184 at the first frame down to 1 — fitted, not knotted, because a pure\n * exponential lands inside a pixel at every one of the eleven frames it was\n * checked against. It never actually arrives, which is the point: this shot is\n * still shedding scale at frame 90, and a shot that truly settles reads as a\n * freeze-frame with a marquee glued on.\n */\nexport function cameraScale(t: number): number {\n  return 1 + ZOOM * ease(t);\n}\n\nfunction knots(\n  ts: readonly number[],\n  vs: readonly number[],\n  t: number,\n): number {\n  return interpolate(t, ts as number[], vs as number[], {\n    extrapolateLeft: \"clamp\",\n    extrapolateRight: \"clamp\",\n  });\n}\n\n/**\n * The top row, streaming left, in content px — its **own** drift, with the\n * camera and the exit pan both taken out.\n *\n * Tracked by aligning each frame against the next *in content space*, undoing\n * the camera first, so what is left is the row's motion and nothing else. A\n * plain screen-space correlation cannot tell a row sliding left from a camera\n * pulling back, and cheerfully reports a decelerating drift for a scene that\n * has none.\n *\n * Then the pan is subtracted, and that subtraction is the check on the whole\n * decomposition: the raw track runs to −372 and never flattens, but −372 minus\n * the pan lands on −258.8 at 3.73 and stays there to the last frame. The rows\n * stop; the camera does not. Left in as measured, the pan gets counted twice\n * and the top row is 34px past the reference by the final second.\n */\nexport const ROW1_T = [\n  0, 0.322, 0.564, 0.964, 1.455, 1.964, 3.172, 3.497, 3.73, 4.005,\n];\nexport const ROW1_V = [\n  0, -69.7, -104.5, -144.2, -178.2, -204.5, -242.8, -248.9, -254.8, -258.8,\n];\n\n/** The bottom row, streaming right — front-loaded where the top row is not. */\nexport const ROW3_T = [\n  0, 0.164, 0.247, 0.322, 0.564, 0.805, 1.047, 1.405, 1.855, 2.447, 3.047,\n  3.364, 4.005,\n];\nexport const ROW3_V = [\n  0, 58.2, 93.6, 119.7, 175.8, 216.2, 247.4, 282.6, 314.5, 342.2, 357.9, 363,\n  365,\n];\n\n/** Where a row sits, in content px. The middle row does not drift at all. */\nexport function rowDrift(row: 0 | 1 | 2, t: number): number {\n  if (row === 0) return knots(ROW1_T, ROW1_V, t);\n  if (row === 2) return knots(ROW3_T, ROW3_V, t);\n  return 0;\n}\n\n/**\n * Where each outer row's slot 0 starts, so the first frame frames like the\n * reference's.\n *\n * Free parameters — the content is ours, so which card sits where is a choice —\n * but not arbitrary ones: these put every monogram within 10px of the\n * reference's for all 121 frames, which is what lets the two clips be diffed\n * on top of each other rather than only compared beat for beat.\n */\nexport const ROW_PHASE = [-118, 0, -142.3];\n\n/**\n * The push out of the shot, in content px.\n *\n * Zero for three seconds and then everything — rows, pill, pointer — leaves\n * together, which is what makes it read as a camera and not as more marquee.\n * Measured on the pill's own centre, the one thing in frame with no drift of\n * its own to subtract first.\n */\nexport const PAN_T = [\n  0, 2.95, 3.014, 3.247, 3.447, 3.564, 3.73, 3.814, 3.93, 3.972, 4.005,\n];\nexport const PAN_V = [\n  0, 0, -1, -6.5, -16.5, -25.5, -43.4, -55.9, -82.4, -95.4, -113.4,\n];\n\nexport function pan(t: number): number {\n  return knots(PAN_T, PAN_V, t);\n}\n\n/**\n * How much room the middle row leaves either side of the pill, in content px,\n * as `[floor, amplitude, time constant]`.\n *\n * Its two flanking cards close in — 91 → 51 on the left, 123 → 65 on the right\n * — on the same shape as the camera and, near enough, the same clock: 0.80s and\n * 0.91s against the camera's 0.75s. Near enough to read as one settle, far\n * enough that sharing the camera's number literally puts the right-hand card 5px\n * wide through the first half second.\n *\n * They are asymmetric and stay asymmetric, which is why this is two rows and not\n * one gap: forcing them equal put the right-hand card 14px wrong for a whole\n * second, and a card 14px out of place beside a pill that never moves is the one\n * misalignment the eye finds.\n *\n * This is also the reading that killed \"the middle row is a marquee too\". Over\n * four seconds its left card travels *right* by 40px while its right card\n * travels left by 58, and no single translation does that.\n */\nexport const CLEARANCE = {\n  left: [51, 57.3, 0.805],\n  right: [65, 79.7, 0.91],\n} as const;\n\nexport function clearance(side: \"left\" | \"right\", t: number): number {\n  const [floor, amp, tau] = CLEARANCE[side];\n  return floor + amp * Math.exp(-Math.max(0, t) / tau);\n}\n\n/**\n * The pill's own scale under the press.\n *\n * Down in 0.18s, back in 0.53s — three times as long coming up as going down,\n * which is the whole reason a click feels like a click. Symmetric, it feels\n * like a bounce.\n */\nexport const PRESS_T = [\n  1.622, 1.689, 1.764, 1.805, 1.897, 1.964, 2.047, 2.122, 2.205, 2.255, 2.33,\n];\nexport const PRESS_V = [\n  1, 0.969, 0.946, 0.931, 0.949, 0.958, 0.968, 0.977, 0.986, 0.995, 1,\n];\n\nexport function pressScale(t: number): number {\n  return knots(PRESS_T, PRESS_V, t);\n}\n\n/** When the pill turns over. Instant in the reference — no crossfade to find. */\nexport const FLIP_AT = 1.689;\n\n/**\n * The pointer, in content px from `ORIGIN`.\n *\n * It arrives in two moves, not one: a fast approach that eases out to a hover\n * about 30px below the pill around t = 0.9, then a second, *accelerating* drop\n * onto the target. That second move peaks at 112px/s — quicker than anything in\n * the first — and it is what makes the click read as a decision rather than as\n * an arrival.\n */\nexport const CURSOR_T = [\n  0, 0.164, 0.247, 0.322, 0.414, 0.489, 0.564, 0.722, 0.889, 0.93, 1.047, 1.164,\n  1.289, 1.405, 2.03, 2.089, 2.172, 2.255, 2.33, 2.414, 2.505, 2.605, 2.73,\n  2.897, 3.089, 3.289, 3.497, 3.689, 4.005,\n];\nexport const CURSOR_X = [\n  123, 117.8, 110.6, 106, 103.8, 102.3, 101.7, 101.3, 101.6, 101.6, 101.8,\n  102.5, 103.6, 103.7, 104.9, 107, 112.1, 121.1, 133, 143, 150.2, 158, 163.6,\n  168.8, 173, 175.4, 177.9, 178.4, 178.2,\n];\nexport const CURSOR_Y = [\n  89.5, 85.4, 76.1, 65.6, 56.6, 49.1, 43.2, 35.4, 30.2, 28.2, 22.2, 13.8, -0.2,\n  -2.6, -2.6, 0.5, 5.8, 16.4, 29.6, 40.4, 48.3, 56.8, 62.7, 65.6, 72.9, 75.8,\n  77.6, 78.5, 78.7,\n];\n\n/**\n * How far inside the pill's trailing edge the pointer comes to rest, in\n * reference px.\n *\n * Measured: it stops 104px right of centre on a pill 122px wide either side —\n * 18px in from the edge, past the icon rather than on it. Kept as an *inset*\n * rather than as an absolute x, because the pill is content-sized and a short\n * label would otherwise leave the pointer clicking thin air beside it.\n */\nexport const LAND_INSET = 18;\n/** The pill the track was measured against, half-width in content px. */\nexport const REF_PILL_HALF = 122;\n\n/**\n * The pointer's place at `t`, in content px from `ORIGIN`.\n *\n * The measured track is the track everywhere except over the pill: there x is\n * pulled in to the pill's own trailing edge, and the pull fades in across the\n * pill's height so no frame ever jumps. Scaling the *whole* track by the pill's\n * width instead moved the pointer's entry and exit too — 13px at the first\n * frame, on a path that has nothing to do with how wide the button is.\n */\nexport function cursorAt(\n  t: number,\n  pillHalf: number,\n): { x: number; y: number } {\n  const x = knots(CURSOR_T, CURSOR_X, t);\n  const y = knots(CURSOR_T, CURSOR_Y, t);\n  const over = Math.min(1, Math.max(0, (PILL.h * 1.5 - Math.abs(y)) / PILL.h));\n  const pull = Math.max(0, x - (pillHalf - LAND_INSET));\n  return { x: x - pull * over, y };\n}\n\n/**\n * When the first monogram turns over, and how often after that.\n *\n * Seven frames, not the 7.25 the five measured onsets average to. Four of those\n * five land on a 7-frame grid off 2.333 to the frame; averaging instead put\n * three of them a frame late to buy back one that is two frames early, and a\n * cascade that is consistently a frame behind is worse than one that is right\n * four times out of five.\n */\nexport const GRANT_AT = 70 / 30;\nexport const GRANT_STEP = 7 / 30;\n\nexport function granted(order: number, t: number): boolean {\n  // A frame's worth of slack, because `70 / 30 + 2 * (7 / 30)` is 2.8000000000000003\n  // and the frame it is supposed to fire on is 2.8. Without it the third turn\n  // lands one frame late and nothing in the code says why.\n  return t + 1e-6 >= GRANT_AT + GRANT_STEP * order;\n}\n\n/* ─────────────────────────────────────────────────────────────────────────\n   Content\n   ───────────────────────────────────────────────────────────────────────── */\n\nexport interface RosterEntry {\n  /** Shown large. */\n  name: string;\n  /** Shown small, under it. */\n  role: string;\n  /** Two characters at most. Derived from `name` when omitted. */\n  initials?: string;\n}\n\n/**\n * What snapcn is granting: its own registry.\n *\n * Four per row, because at this pitch a row shows three cards at once and a\n * roster of three tiles visibly across the frame.\n */\nexport const SNAPCN_ROSTER: readonly (readonly RosterEntry[])[] = [\n  [\n    { name: \"Text Reveal\", role: \"Animation\" },\n    { name: \"Prompt Send\", role: \"Composition\" },\n    { name: \"Logo Drift\", role: \"Background\" },\n    { name: \"Word Flip\", role: \"Animation\" },\n  ],\n  [\n    { name: \"Count Grid\", role: \"Composition\" },\n    { name: \"Agent Steps\", role: \"Composition\" },\n    { name: \"Type Morph\", role: \"Animation\" },\n    { name: \"Text Swell\", role: \"Animation\" },\n  ],\n  [\n    { name: \"Karaoke Captions\", role: \"Composition\" },\n    { name: \"Search Typing\", role: \"Composition\" },\n    { name: \"Text Highlight\", role: \"Animation\" },\n    { name: \"Orbit Gallery\", role: \"Composition\" },\n  ],\n];\n\n/**\n * Which turn each row takes, over two passes of the three rows.\n *\n * The reference goes top, middle, bottom, top, **bottom, middle** — the second\n * pass swaps the last two, so no row ever grants twice running and the sixth\n * monogram does not land where the third did. Six is the whole visible cascade;\n * it repeats from there.\n */\nexport const TURNS = [\n  [0, 3],\n  [1, 5],\n  [2, 4],\n] as const;\n\nexport function turnOf(row: number, step: number): number {\n  return 6 * Math.floor(step / 2) + (TURNS[row % 3]?.[step % 2] ?? 0);\n}\n\n/**\n * Which roster entry a row starts its cascade on.\n *\n * Not entry 0. The marquee has moved 200-odd pixels by the time anything is\n * granted, so whichever entry sits at slot 0 is wherever the drift table left\n * it — keyed on entry 0, the cascade opened on a card whose avatar was 73px off\n * the left edge, and the reference's frame-70 grant did not appear until frame\n * 78. Seeding on the entry nearest the middle of the frame at `GRANT_AT` puts\n * the first monogram where a viewer is already looking, for any phase, any\n * drift and any roster length.\n *\n * Keyed on the roster entry rather than on the marquee slot, so every copy of a\n * card on screen turns over on the same frame: a component is installed once,\n * not once per place it is drawn.\n */\nexport function grantSeed(\n  row: 0 | 1 | 2,\n  len: number,\n  pillHalf: number,\n): number {\n  // The *monogram's* distance from the middle, not the card's: a card can be\n  // half on screen with its avatar 65px past the left edge, and a grant nobody\n  // can see is a grant that did not happen. Seeding on the card instead put the\n  // second turn nine frames behind the reference's.\n  const reach = REF_W / 2 / cameraScale(GRANT_AT);\n  let left = Number.NEGATIVE_INFINITY;\n  let leftSlot: number | null = null;\n  let near = Number.POSITIVE_INFINITY;\n  let nearSlot = 0;\n  for (const { slot, u } of slotsFor(row, GRANT_AT, pillHalf)) {\n    const disc = u - CARD.w / 2 + AVATAR.padX + AVATAR.size / 2;\n    if (Math.abs(disc) > reach - AVATAR.size / 2) continue;\n    if (disc <= 0 && disc > left) {\n      left = disc;\n      leftSlot = slot;\n    }\n    if (Math.abs(disc) < near) {\n      near = Math.abs(disc);\n      nearSlot = slot;\n    }\n  }\n  // The nearest monogram *left* of centre, not simply the nearest — because the\n  // next entry in the roster is one slot to the right, and a cascade seeded on\n  // the right-hand card sends its own second turn off the right edge. That is\n  // what the reference does in all three rows, and the one row where it cannot\n  // (the middle: the pill hides the card to its left) is the one row it seeds on\n  // the right.\n  const best = leftSlot ?? nearSlot;\n  return ((best % len) + len) % len;\n}\n\nexport function grantOrderOf(\n  row: 0 | 1 | 2,\n  entryIndex: number,\n  len: number,\n  seed: number,\n): number {\n  return turnOf(row, (((entryIndex - seed) % len) + len) % len);\n}\n\nexport function initialsOf(entry: RosterEntry): string {\n  if (entry.initials) return entry.initials;\n  return entry.name\n    .split(/\\s+/)\n    .slice(0, 2)\n    .map((w) => w[0] ?? \"\")\n    .join(\"\")\n    .toUpperCase();\n}\n\n/* ─────────────────────────────────────────────────────────────────────────\n   Layout\n   ───────────────────────────────────────────────────────────────────────── */\n\n/**\n * Inter's advance widths, in em, for the characters a button label uses.\n *\n * The pill is drawn `width: max-content`, so the *drawn* pill is always exactly\n * its content plus its padding and no label can ever be cramped. This table is\n * for everything that has to know how wide that pill will be **before** it is\n * drawn — where the middle row's cards sit either side of it, and where the\n * pointer lands on it.\n *\n * It replaced \"0.52em to the character\", which read a 130px label as 216 and\n * left the pill 30px wider than its own contents: balanced padding, and 15px\n * too much of it on each side. A per-character table is 30 lines of data and it\n * gets \"Install all\" to within a pixel; a single average cannot get any label\n * right, because the whole point of a label is that you do not know it yet.\n */\nconst ADVANCE: Record<string, number> = {\n  \" \": 0.26,\n  \"-\": 0.35,\n  \".\": 0.27,\n  \",\": 0.27,\n  \"'\": 0.19,\n  \"!\": 0.29,\n  a: 0.541,\n  b: 0.578,\n  c: 0.512,\n  d: 0.578,\n  e: 0.541,\n  f: 0.34,\n  g: 0.578,\n  h: 0.552,\n  i: 0.24,\n  j: 0.24,\n  k: 0.512,\n  l: 0.24,\n  m: 0.827,\n  n: 0.552,\n  o: 0.571,\n  p: 0.578,\n  q: 0.578,\n  r: 0.351,\n  s: 0.501,\n  t: 0.35,\n  u: 0.552,\n  v: 0.499,\n  w: 0.753,\n  x: 0.501,\n  y: 0.499,\n  z: 0.474,\n  A: 0.665,\n  B: 0.654,\n  C: 0.677,\n  D: 0.7,\n  E: 0.6,\n  F: 0.578,\n  G: 0.72,\n  H: 0.71,\n  I: 0.273,\n  J: 0.531,\n  K: 0.644,\n  L: 0.57,\n  M: 0.872,\n  N: 0.73,\n  O: 0.747,\n  P: 0.635,\n  Q: 0.747,\n  R: 0.635,\n  S: 0.614,\n  T: 0.601,\n  U: 0.71,\n  V: 0.665,\n  W: 0.948,\n  X: 0.632,\n  Y: 0.619,\n  Z: 0.601,\n};\n/** Digits are one width in Inter, and anything unlisted gets a lowercase mean. */\nconst ADVANCE_FALLBACK = (ch: string) => (/[0-9]/.test(ch) ? 0.6 : 0.55);\n\n/** How wide the label's text runs, in reference px. */\nexport function labelWidth(label: string): number {\n  let em = 0;\n  let spaces = 0;\n  for (const ch of label) {\n    em += ADVANCE[ch] ?? ADVANCE_FALLBACK(ch);\n    if (ch === \" \") spaces++;\n  }\n  return em * PILL.label + spaces * PILL.wordSpacing;\n}\n\n/** The pill's width, in reference px — content plus the measured padding. */\nexport function pillWidth(label: string): number {\n  return PILL.padX * 2 + labelWidth(label.trim()) + PILL.iconGap + PILL.iconW;\n}\n\n/**\n * Where a card sits at rest, in reference px — before the row's own motion.\n *\n * Rows 0 and 2 are plain marquees on a pitch. Row 1 is two stacks anchored to\n * the pill's edges at their *closed* clearance, with the slot behind the pill\n * left empty — see `CLEARANCE` for why it cannot be a marquee.\n */\nexport function slotRest(\n  row: 0 | 1 | 2,\n  slot: number,\n  pillHalf: number,\n): number {\n  if (row !== 1) return (ROW_PHASE[row] ?? 0) + slot * CARD_PITCH;\n  const edge = pillHalf + CARD.w / 2;\n  return slot < 0\n    ? -(edge + CLEARANCE.left[0]) + (slot + 1) * CARD_PITCH\n    : edge + CLEARANCE.right[0] + slot * CARD_PITCH;\n}\n\n/**\n * How far a row (or, for the middle row, one of its two stacks) has moved from\n * rest at `t` — the one number that is animated, per group, per frame.\n */\nexport function rowShift(row: 0 | 1 | 2, slot: number, t: number): number {\n  if (row !== 1) return rowDrift(row, t);\n  const side = slot < 0 ? \"left\" : \"right\";\n  const open = clearance(side, t) - CLEARANCE[side][0];\n  return side === \"left\" ? -open : open;\n}\n\n/** Where a card actually is at `t`, in reference px. */\nexport function slotsFor(\n  row: 0 | 1 | 2,\n  t: number,\n  pillHalf: number,\n): { slot: number; u: number }[] {\n  return slotRange(row, pillHalf).map((slot) => ({\n    slot,\n    u: slotRest(row, slot, pillHalf) + rowShift(row, slot, t),\n  }));\n}\n\n/**\n * Every slot of a row that reaches the frame at **any** point in the clip.\n *\n * Fixed, so the DOM never changes: a card that is drawn is drawn for all 120\n * frames and only its group's `translateX` moves. Mounting and unmounting cards\n * as they cross the edge is a layout pass on a frame that also has to composite\n * a camera move, and it lands on exactly the frames a marquee is least able to\n * hide it — the ones where something is entering.\n */\nexport function slotRange(row: 0 | 1 | 2, pillHalf: number): number[] {\n  let lo = Number.POSITIVE_INFINITY;\n  let hi = Number.NEGATIVE_INFINITY;\n  // 0.05s is a quarter of the fastest thing in the clip; the union cannot open\n  // and close again between two samples.\n  for (let t = 0; t <= 4.2; t += 0.05) {\n    const reach = REF_W / 2 / cameraScale(t) + CARD.w;\n    lo = Math.min(lo, -pan(t) - reach);\n    hi = Math.max(hi, -pan(t) + reach);\n  }\n  // The middle row's stacks are indexed -1, -2, … and 0, 1, … — there is no\n  // centre slot to skip, because the pill *is* the gap.\n  const out: number[] = [];\n  for (let slot = -12; slot <= 12; slot++) {\n    let seen = false;\n    for (let t = 0; t <= 4.2 && !seen; t += 0.05) {\n      const u = slotRest(row, slot, pillHalf) + rowShift(row, slot, t);\n      if (u > lo && u < hi) seen = true;\n    }\n    if (seen) out.push(slot);\n  }\n  return out;\n}\n\n/* ─────────────────────────────────────────────────────────────────────────\n   Component\n   ───────────────────────────────────────────────────────────────────────── */\n\nexport interface RosterGrantProps {\n  /** Three rows of cards. Each row repeats across the frame. */\n  rows?: readonly (readonly RosterEntry[])[];\n  /** The pill's label. */\n  label?: string;\n  /** Overrides the design system's `primary` for the pill and the monograms. */\n  accentColor?: string;\n  /** Design-system token overrides. */\n  theme?: Partial<SnapCnTheme>;\n  mode?: \"light\" | \"dark\";\n  /**\n   * The face this scene paints its words in — a label from `fonts.ts` or a CSS\n   * family you have loaded yourself. Overrides `theme.fontFamily`.\n   */\n  fontFamily?: string;\n  /** 1 is the measured speed. */\n  speed?: number;\n}\n\nexport function RosterGrant({\n  rows = SNAPCN_ROSTER,\n  label = \"Install all\",\n  accentColor,\n  theme,\n  mode,\n  fontFamily,\n  speed = 1,\n}: RosterGrantProps) {\n  const frame = useCurrentFrame();\n  const { fps, width, height } = useVideoConfig();\n  // `frame * speed`, so 2 is twice as fast — the convention every other timed\n  // scene in this registry uses.\n  const t = (frame * speed) / fps;\n\n  const th = useSnapCnTheme(theme, mode);\n  const accent = accentColor ?? th.primary;\n  const face = resolveFont(fontFamily ?? th.fontFamily) ?? SANS;\n\n  // Reference px → render px. The whole scene is laid out once in the\n  // reference's own 712×398 and then scaled here, so nothing below this line\n  // depends on the render size.\n  const k = Math.min(width / REF_W, height / REF_H);\n  const ox = (width - REF_W * k) / 2;\n  const oy = (height - REF_H * k) / 2;\n\n  const half = pillWidth(label) / 2;\n  const point = cursorAt(t, half);\n\n  // A hairline that belongs to the palette: the token walked most of the way\n  // back toward the fill it edges, because `border` at full strength is a\n  // shadcn *control* border and these are 76px chips, not controls.\n  const edge = mixOklch(th.secondary, th.border, 0.55);\n\n  // `will-change` is right for the Player and wrong for the render. One\n  // continuous tab with an 8ms budget wants the camera handed to the\n  // compositor; a render is spread across parallel tabs, each of which would\n  // inherit a stale raster from whatever scale *it* drew last.\n  const live = !getRemotionEnvironment().isRendering\n    ? { willChange: \"transform\" as const }\n    : null;\n\n  // Fixed for the whole clip, so this is a `useMemo` and not a per-frame scan.\n  const ranges = useMemo(\n    () => [slotRange(0, half), slotRange(1, half), slotRange(2, half)],\n    [half],\n  );\n\n  const groups: ReactNode[] = [];\n  // An entry's index in `rows` read row by row — what Studio calls it by.\n  let base = 0;\n  for (const row of [0, 1, 2] as const) {\n    const roster = rows[row] ?? [];\n    const first = base;\n    base += roster.length;\n    if (roster.length === 0) continue;\n    const seed = grantSeed(row, roster.length, half);\n    // A row repeats its entries across the frame. Studio outlines the copy\n    // nearest the middle of the frame; the others are only pictures of it.\n    const nearest = new Map<number, number>();\n    const held = new Map<number, number>();\n    for (const slot of ranges[row] ?? []) {\n      const i = ((slot % roster.length) + roster.length) % roster.length;\n      const d = Math.abs(\n        slotRest(row, slot, half) + rowShift(row, slot, t) + pan(t),\n      );\n      if (d < (held.get(i) ?? Number.POSITIVE_INFINITY)) {\n        held.set(i, d);\n        nearest.set(i, slot);\n      }\n    }\n    const y = ORIGIN.y + (row - 1) * ROW_PITCH - CARD.h / 2;\n    // One group per thing that moves: a whole row, or — for the middle row —\n    // each side of the pill, which close in at different rates.\n    const sides = row === 1 ? ([-1, 1] as const) : ([0] as const);\n    for (const side of sides) {\n      const slots = (ranges[row] ?? []).filter((n) =>\n        row === 1 ? (side < 0 ? n < 0 : n >= 0) : true,\n      );\n      if (slots.length === 0) continue;\n      groups.push(\n        <div\n          key={`${row}:${side}`}\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            transform: `translateX(${rowShift(row, side, t)}px)`,\n            ...live,\n          }}\n        >\n          {slots.map((slot) => {\n            const i = ((slot % roster.length) + roster.length) % roster.length;\n            const entry = roster[i];\n            if (!entry) return null;\n            return (\n              <Item\n                key={slot}\n                index={first + i}\n                primary={nearest.get(i) === slot}\n              >\n                <Card\n                  accent={accent}\n                  edge={edge}\n                  entry={entry}\n                  left={slotRest(row, slot, half) + ORIGIN.x - CARD.w / 2}\n                  on={granted(grantOrderOf(row, i, roster.length, seed), t)}\n                  th={th}\n                  top={y}\n                />\n              </Item>\n            );\n          })}\n        </div>,\n      );\n    }\n  }\n\n  return (\n    <AbsoluteFill\n      style={{\n        backgroundColor: th.background,\n        fontFamily: face,\n        // Hinting re-snaps every stem as the camera scale slides and the\n        // letterforms boil. This is the fix, and it is not optional in a scene\n        // that never stops scaling.\n        textRendering: \"geometricPrecision\",\n        overflow: \"hidden\",\n      }}\n    >\n      {/* A transparent page asks for no page, and the backdrop is the page. */}\n      {parseColor(th.background).alpha !== 0 && (\n        <Backdrop accent={accent} th={th} />\n      )}\n      <div\n        style={{\n          position: \"absolute\",\n          left: ox,\n          top: oy,\n          width: REF_W,\n          height: REF_H,\n          transform: `scale(${k})`,\n          transformOrigin: \"0 0\",\n        }}\n      >\n        {/* The camera. Everything under it is laid out once, at scale 1, and\n            nothing in the scene animates a size or a position — only this\n            transform and one `translateX` per row. Transforms do not reflow;\n            an animated `fontSize` re-shapes every glyph in the frame on every\n            frame, which is the most expensive thing a browser can be asked to\n            do per frame and the reason the same scene can measure correct and\n            still look like it is sticking. */}\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            transform: `translateX(${pan(t) * cameraScale(t)}px) scale(${cameraScale(t)})`,\n            transformOrigin: `${ORIGIN.x}px ${ORIGIN.y}px`,\n            ...live,\n          }}\n        >\n          {groups}\n          <Pill\n            accent={accent}\n            label={label}\n            on={t >= FLIP_AT}\n            press={pressScale(t)}\n            th={th}\n          />\n          <Pointer color={th.foreground} rim={th.background} at={point} />\n        </div>\n      </div>\n    </AbsoluteFill>\n  );\n}\n\n/* ─────────────────────────────────────────────────────────────────────────\n   Pieces — all laid out in reference px, none of them animated\n   ───────────────────────────────────────────────────────────────────────── */\n\n/**\n * One roster card. Takes a `ref` and a `style` on top of its own so Remotion\n * Studio can outline it and nudge it (see `Item`).\n */\nconst Card = forwardRef<\n  HTMLDivElement,\n  {\n    accent: string;\n    edge: string;\n    entry: RosterEntry;\n    left: number;\n    on: boolean;\n    th: SnapCnTheme;\n    top: number;\n    style?: CSSProperties;\n  }\n>(function Card({ accent, edge, entry, left, on, th, top, style }, ref) {\n  return (\n    <div\n      ref={ref}\n      style={{\n        ...style,\n        position: \"absolute\",\n        left,\n        top,\n        width: CARD.w,\n        height: CARD.h,\n        borderRadius: CARD.radius,\n        background: th.secondary,\n        // A hairline and nothing else. A drop shadow under nine light chips on\n        // a light page is nine grey smears — and the reference's own card edge\n        // is five levels of luma, which is a border, not a shadow.\n        boxShadow: `inset 0 0 0 1px ${edge}`,\n        overflow: \"hidden\",\n      }}\n    >\n      <div\n        style={{\n          position: \"absolute\",\n          left: AVATAR.padX,\n          top: (CARD.h - AVATAR.size) / 2,\n          width: AVATAR.size,\n          height: AVATAR.size,\n          borderRadius: \"50%\",\n          background: on ? accent : th.card,\n          color: on ? th.primaryForeground : th.foreground,\n          display: \"flex\",\n          alignItems: \"center\",\n          justifyContent: \"center\",\n          fontSize: AVATAR.initials,\n          fontWeight: 500,\n          lineHeight: 1,\n        }}\n      >\n        {initialsOf(entry)}\n      </div>\n      <div\n        style={{\n          position: \"absolute\",\n          left: TEXT_X,\n          top: NAME.top,\n          right: 10,\n          fontSize: NAME.size,\n          fontWeight: NAME.weight,\n          lineHeight: 1,\n          color: th.foreground,\n          whiteSpace: \"nowrap\",\n          overflow: \"hidden\",\n          textOverflow: \"ellipsis\",\n        }}\n      >\n        {entry.name}\n      </div>\n      <div\n        style={{\n          position: \"absolute\",\n          left: TEXT_X,\n          top: ROLE.top,\n          right: 10,\n          fontSize: ROLE.size,\n          fontWeight: ROLE.weight,\n          lineHeight: 1,\n          color: th.mutedForeground,\n          whiteSpace: \"nowrap\",\n          overflow: \"hidden\",\n          textOverflow: \"ellipsis\",\n        }}\n      >\n        {entry.role}\n      </div>\n    </div>\n  );\n});\n\nfunction Pill({\n  accent,\n  label,\n  on,\n  press,\n  th,\n}: {\n  accent: string;\n  label: string;\n  on: boolean;\n  press: number;\n  th: SnapCnTheme;\n}) {\n  const fill = on ? accent : th.foreground;\n  return (\n    <div\n      style={{\n        position: \"absolute\",\n        left: ORIGIN.x,\n        top: ORIGIN.y,\n        // `max-content`, so the pill is its own contents plus the measured\n        // padding and a long label can never be cramped inside a guessed width.\n        width: \"max-content\",\n        height: PILL.h,\n        padding: `0 ${PILL.padX}px`,\n        boxSizing: \"border-box\",\n        transform: `translate(-50%, -50%) scale(${press})`,\n        borderRadius: PILL.radius,\n        background: fill,\n        color: on ? th.primaryForeground : th.background,\n        display: \"flex\",\n        alignItems: \"center\",\n        justifyContent: \"center\",\n        gap: PILL.iconGap,\n        fontSize: PILL.label,\n        fontWeight: 500,\n        wordSpacing: PILL.wordSpacing,\n        lineHeight: 1,\n        whiteSpace: \"nowrap\",\n        // A 1px lighter rim along the top, which is what the reference has and\n        // what stops a saturated pill reading as a sticker, plus a glow in the\n        // pill's *own* colour — so it can never be the grey smear a neutral\n        // drop shadow would be on this page.\n        boxShadow: [\n          `inset 0 1px 0 ${withAlpha(\"#ffffff\", 0.22)}`,\n          `0 10px 26px -6px ${withAlpha(fill, 0.34)}`,\n        ].join(\", \"),\n      }}\n    >\n      <span>{label}</span>\n      <svg\n        width={PILL.iconW}\n        height={PILL.iconH}\n        viewBox=\"0 0 24 20\"\n        fill=\"none\"\n        stroke=\"currentColor\"\n        strokeWidth={1.8}\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        aria-hidden\n      >\n        <title>Install</title>\n        <path d=\"M12 1.5v10.5\" />\n        <path d=\"M7.5 7.5 12 12l4.5-4.5\" />\n        <path d=\"M3.5 14.5v3a1.5 1.5 0 0 0 1.5 1.5h14a1.5 1.5 0 0 0 1.5-1.5v-3\" />\n      </svg>\n    </div>\n  );\n}\n\n/**\n * The pointer — lucide's `MousePointer2`, filled, with a rim in the page colour\n * so it reads over a card, over the pill and over the backdrop alike.\n *\n * Positioned by its **tip**, not its centre: the reference's pointer is a plain\n * disc and the tracked point is that disc's middle, but an arrow's hotspot is\n * the point it is drawn from. Anchoring the box instead puts the click a third\n * of the glyph away from where the reference clicked.\n */\nfunction Pointer({\n  at,\n  color,\n  rim,\n}: {\n  at: { x: number; y: number };\n  color: string;\n  rim: string;\n}) {\n  return (\n    <svg\n      width={CURSOR.size}\n      height={CURSOR.size}\n      viewBox=\"0 0 24 24\"\n      style={{\n        position: \"absolute\",\n        left: 0,\n        top: 0,\n        transform: `translate(${ORIGIN.x + at.x - CURSOR.tip.x * (CURSOR.size / 24)}px, ${ORIGIN.y + at.y - CURSOR.tip.y * (CURSOR.size / 24)}px)`,\n        overflow: \"visible\",\n      }}\n      aria-hidden\n    >\n      <title>Pointer</title>\n      <path\n        d=\"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z\"\n        fill={color}\n        stroke={rim}\n        strokeWidth={1.6}\n        strokeLinejoin=\"round\"\n      />\n    </svg>\n  );\n}\n\n/**\n * The page under it all.\n *\n * The reference's backdrop is a mesh: white through the middle of the top edge,\n * a wash of its brand indigo climbing out of the bottom-right, and a lighter\n * core right behind the pill. Its *shape* is worth keeping and its paint is\n * not — so the wash here is the accent, at the alphas measured off the\n * reference, and it follows a user's theme instead of a stranger's brand.\n */\nfunction Backdrop({ accent, th }: { accent: string; th: SnapCnTheme }) {\n  return (\n    <AbsoluteFill\n      style={{\n        background: [\n          `radial-gradient(58% 44% at 50% 46%, ${withAlpha(th.card, 0.9)} 0%, ${withAlpha(th.card, 0)} 100%)`,\n          `radial-gradient(78% 62% at 64% 116%, ${withAlpha(accent, 0.42)} 0%, ${withAlpha(accent, 0)} 100%)`,\n          `radial-gradient(52% 46% at -4% -8%, ${withAlpha(accent, 0.16)} 0%, ${withAlpha(accent, 0)} 100%)`,\n          th.background,\n        ].join(\", \"),\n      }}\n    />\n  );\n}\n\nexport default RosterGrant;\n",
      "type": "registry:component",
      "target": "components/snap-cn/roster-grant.tsx"
    }
  ],
  "docs": "Docs and props: https://snapcn.dev/docs/scenes/roster-grant?ref=cli — pass rows as three arrays of { name, role } and label for the button. — 82 Pro components too — charts, launch scenes, device shots: https://snapcn.dev/docs/pricing?ref=cli-docs",
  "type": "registry:component"
}
