{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "portal-intro",
  "title": "Portal Intro",
  "description": "Sentence-to-picture intro. The lead words fade up one at a time, the line re-sets with a small rounded picture chip inside it and leans in until the chip takes the frame; a title types itself over the picture, lifts away, and the mark and the name arrive. Fitted frame by frame from a reference recording.",
  "dependencies": [
    "remotion"
  ],
  "registryDependencies": [
    "https://snapcn.dev/r/snap-cn-ui.json"
  ],
  "files": [
    {
      "path": "registry/snap-cn/portal-intro/index.tsx",
      "content": "// Portal Intro · snapcn — https://snapcn.dev/docs/scenes/portal-intro\n\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport {\n  AbsoluteFill,\n  continueRender,\n  delayRender,\n  getRemotionEnvironment,\n  Img,\n  staticFile,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\nimport {\n  resolveFont,\n  type SnapCnTheme,\n  useSnapCnTheme,\n} from \"@/lib/snap-cn-ui\";\n\n/**\n * A sentence with a picture in it, and the picture opening into the frame.\n *\n * The lead words fade up one at a time while the line drifts in from the left.\n * Then the line re-sets with a small rounded chip in the middle of it and the\n * rest of the sentence after, and the whole thing leans in — slowly at first,\n * then fast — until the chip takes the frame. The picture lands blurred and a\n * little small and settles sharp; a title types itself in over it, lifts away,\n * and the mark and the name arrive in its place.\n *\n * Every number below was measured off a screen recording, frame by frame, and\n * the scene is built on that recording's own clock: it was captured at 30fps,\n * so frame `n` here is frame `n - 1` of the recording and every table is keyed\n * in the recording's frames.\n *\n * ## Two lines, not one line that grows\n *\n * The first line is only the lead words, centred with a trailing space. The\n * second is lead + chip + trail, centred on its own. The recording cuts between\n * them on one frame — nothing slides from one layout to the other — so the\n * scene does too.\n *\n * ## The line scales about a fixed point, not its centre\n *\n * Both lines scale about (PIVOT_X, PIVOT_Y): the second line's measured centre\n * drifts right as it grows, by exactly what a pivot 15px left of it predicts\n * (to 0.4px over 24 frames). The pivot's height is the chip's centre line, and\n * the baseline stays a fixed 7.5px below it at every scale.\n *\n * ## The chip holds its own picture\n *\n * It is not a window onto the backdrop: the chip's picture eases out a touch\n * and then dives in 2.4x on its own while the line leans in, and the backdrop\n * replaces it on the frame the chip opens. Both default to one image.\n */\n\n/** Variable Geist: the recording's weights (450, 500) are between Google's cuts. */\nconst FACE = \"Portal Intro Geist\";\nconst FACE_URL =\n  \"https://cdn.jsdelivr.net/npm/@fontsource-variable/geist@5.2.8/files/geist-latin-wght-normal.woff2\";\nlet faceLoad: Promise<unknown> | null = null;\nfunction loadFace(): Promise<unknown> {\n  if (faceLoad) return faceLoad;\n  if (typeof FontFace === \"undefined\") {\n    faceLoad = Promise.resolve();\n    return faceLoad;\n  }\n  const face = new FontFace(FACE, `url(${FACE_URL}) format(\"woff2\")`, {\n    weight: \"100 900\",\n  });\n  document.fonts.add(face);\n  // A face that fails to load leaves the fallback stack to paint.\n  faceLoad = face.load().catch(() => undefined);\n  return faceLoad;\n}\nconst SANS = `\"${FACE}\", Geist, ui-sans-serif, system-ui, sans-serif`;\n\n/** Absolute, so a copy of this file in another project still finds it. */\nconst DEFAULT_IMAGE =\n  \"https://media.snapcn.dev/demos/showcase/portal-intro.jpg\";\n\n/* ─────────────────────────────────────────────────────────────────────────\n   The frame, in the recording's own 714 × 402 pixels\n   ───────────────────────────────────────────────────────────────────────── */\n\nexport const REF_W = 714;\nexport const REF_H = 402;\n/** Recording frame `r` is composition frame `r + LEAD`. */\nexport const LEAD = 1;\nexport const DURATION = 108;\n\n/** The point both lines scale about. */\nexport const PIVOT_X = 345.17;\nexport const PIVOT_Y = 198.93;\n/** Where each line is centred, at scale 1. */\nexport const CENTRE_A = 357;\nexport const CENTRE_B = 360.27;\n/** The baseline at scale 1. */\nexport const BASELINE = 206.46;\n\n/** The line's type: size at scale 1, weight, tracking in em. */\nexport const LINE_SIZE = 26.834;\nexport const LINE_WEIGHT = 450;\nexport const LINE_TRACKING = -0.01;\n/** Frames between one lead word and the next. */\nexport const STAGGER = 6;\n/** The chip's corner, in layout px — it scales with the line. */\nexport const CHIP_RADIUS = 4.4;\n\n/** The recording frames each part of the scene owns. */\nexport const FIRST_LINE_TO = 22;\nexport const SECOND_LINE_TO = 46;\nexport const OPEN_AT = 49;\nexport const TITLE_FROM = 48;\nexport const TITLE_TO = 70;\nexport const MARK_FROM = 71;\nexport const BRAND_FROM = 73;\nexport const BRAND_STAGGER = 2;\n\n/** The title's type and where it is centred. */\nexport const TITLE_SIZE = 30.29;\nexport const TITLE_WEIGHT = 500;\nexport const TITLE_TRACKING = -0.02;\nexport const TITLE_CENTRE = 357.415;\n/** The mark and name: sizes, gap, centre, and the name's drop below the mark's centre. */\nexport const MARK_SIZE = 29.22;\nexport const BRAND_SIZE = 38.19;\nexport const BRAND_WEIGHT = 450;\nexport const BRAND_TRACKING = -0.03;\nexport const BRAND_GAP = 3.25;\nexport const BRAND_CENTRE = 356.86;\nexport const BRAND_DROP = 10.74;\n/** Where the mark settles once the recording runs out, and how fast. */\nexport const MARK_REST = 199;\nexport const MARK_SETTLE = 0.88;\n\n/**\n * The backdrop is drawn this much larger than the frame, so that at the 0.62\n * scale it opens at there is still picture under every edge of the opening.\n */\nexport const BLEED = 1.5;\n\n/* ─────────────────────────────────────────────────────────────────────────\n   The measured tables, keyed in recording frames\n   ───────────────────────────────────────────────────────────────────────── */\n\nexport type Table = { from: number; v: readonly number[] };\n\n/** Linear read of a table, clamped at both ends. */\nexport function at(t: Table, x: number): number {\n  const n = t.v.length;\n  const i = x - t.from;\n  if (i <= 0) return t.v[0] ?? 0;\n  if (i >= n - 1) return t.v[n - 1] ?? 0;\n  const i0 = Math.floor(i);\n  const a = t.v[i0] ?? 0;\n  const b = t.v[i0 + 1] ?? a;\n  return a + (b - a) * (i - i0);\n}\n\n/** The whole line's scale, against the size it is set at. */\nexport const SCALE: Table = {\n  from: -1,\n  v: [\n    0.948789, 0.948789, 0.948789, 0.949727, 0.9491, 0.94994, 0.950745, 0.950887,\n    0.95062, 0.951965, 0.952448, 0.953167, 0.95334, 0.954234, 0.955356,\n    0.956136, 0.957932, 0.959057, 0.961321, 0.963993, 0.96696, 0.970379,\n    0.97696, 0.985827, 1.00001, 1.01553, 1.02495, 1.03178, 1.0374, 1.04274,\n    1.04826, 1.05222, 1.05734, 1.06323, 1.06908, 1.07466, 1.08109, 1.08821,\n    1.09531, 1.10385, 1.1126, 1.12312, 1.13474, 1.14857, 1.16463, 1.18435,\n    1.21107, 1.26697,\n  ],\n};\n/** How far the first line still has to travel right, in layout px. */\nexport const PAN: Table = {\n  from: -1,\n  v: [\n    -57, -44.2, -34.069, -25.946, -20.352, -15.946, -12.41, -9.611, -7.358,\n    -5.421, -3.863, -2.598, -1.655, -0.897, -0.338, 0.013, 0.226, 0.236, 0.249,\n    0.225, 0.19, 0.086, 0.055, -0.045,\n  ],\n};\n/** A word's opacity, by frames since it began. */\nexport const WORD_OPACITY: Table = {\n  from: -1,\n  v: [\n    0, 0.15, 0.317, 0.457, 0.563, 0.642, 0.706, 0.754, 0.804, 0.812, 0.871,\n    0.888, 0.909, 0.933, 0.949, 0.964, 0.981, 0.996, 0.988, 0.993, 0.994, 0.999,\n    1, 1,\n  ],\n};\n/** How far below its baseline a word still is, by frames since it began. */\nexport const WORD_RISE: Table = {\n  from: -1,\n  v: [\n    4.58, 3.907, 3.314, 2.797, 2.348, 1.962, 1.632, 1.354, 1.12, 0.926, 0.764,\n    0.629, 0.516, 0.418, 0.333, 0.261, 0.2, 0.148, 0.104, 0.066, 0.034, 0.005,\n    0, 0,\n  ],\n};\n/** The room the line makes for the chip, in layout px. */\nexport const SLOT: Table = {\n  from: 23,\n  v: [\n    60.732, 65.134, 67.143, 68.482, 69.546, 70.405, 71.05, 71.649, 72.167,\n    72.54, 72.803, 73.062, 73.292, 73.382, 73.481, 73.663, 74.218, 75.148,\n    76.582, 78.659, 81.609, 85.948, 92.559, 109.382,\n  ],\n};\n/** The chip's drawn width, in layout px. */\nexport const CHIP_W: Table = {\n  from: 23,\n  v: [\n    44.508, 45.945, 46.76, 47.144, 47.798, 47.894, 48.001, 48.454, 48.466,\n    48.546, 48.653, 48.693, 48.885, 49.032, 49.904, 51.058, 52.22, 54.09,\n    56.437, 59.433, 63.447, 69.108, 77.2, 96.579,\n  ],\n};\n/** The chip's drawn height, in layout px. */\nexport const CHIP_H: Table = {\n  from: 23,\n  v: [\n    25.253, 26.036, 26.521, 26.778, 26.907, 27.012, 27.039, 27.174, 27.431,\n    27.515, 27.597, 27.85, 28.043, 28.097, 28.312, 28.967, 29.719, 30.467,\n    31.741, 33.415, 35.677, 38.81, 43.202, 54.168,\n  ],\n};\n/** Where the chip sits in its slot, off centre, in layout px. */\nexport const CHIP_DX: Table = {\n  from: 23,\n  v: [\n    -0.662, -1.12, -1.266, -1.491, -1.497, -1.626, -1.705, -1.681, -1.744,\n    -1.766, -1.773, -1.828, -1.882, -1.924, -1.888, -1.869, -1.95, -1.931,\n    -2.032, -2.236, -2.339, -2.701, -3.151, -4.166,\n  ],\n};\n/** And off the pivot line, in layout px. */\nexport const CHIP_DY: Table = {\n  from: 23,\n  v: [\n    0.241, 0.197, 0.166, 0.154, 0.169, 0.179, 0.195, 0.171, 0.192, 0.177, 0.155,\n    0.17, 0.16, 0.091, 0.078, 0.107, 0.088, 0.081, 0.074, 0.113, 0.045, 0.09,\n    0.022, 0.055,\n  ],\n};\n/** The picture inside the chip, as a zoom over `cover`. */\nexport const CHIP_ZOOM: Table = {\n  from: 23,\n  v: [\n    1.3053, 1.2221, 1.1553, 1.1025, 1.062, 1.0324, 1.0126, 1.002, 1, 1.0065,\n    1.0215, 1.045, 1.0777, 1.12, 1.1728, 1.2372, 1.3146, 1.4068, 1.5158, 1.6442,\n    1.7952, 1.9726, 2.1809, 2.4258,\n  ],\n};\n/** The backdrop's scale once the chip has opened. */\nexport const BG_SCALE: Table = {\n  from: 47,\n  v: [\n    0.6285, 0.7741, 0.8335, 0.8644, 0.8844, 0.9068, 0.9271, 0.9434, 0.9558,\n    0.9633, 0.9687, 0.9745, 0.9804, 0.9861, 0.993, 0.9972, 1.0004, 1.0028,\n    1.0046, 1.0061, 1.0076, 1.0073, 1.0072, 1.0069, 1.0065, 1.0053, 1.0045,\n    1.0037, 1.0023, 1.0019, 1.0018, 1.0016, 1.0011, 1.001, 1.0009, 1.0006,\n    1.0004, 1.0001, 1, 1,\n  ],\n};\n/** Its drift right, in reference px. */\nexport const BG_X: Table = {\n  from: 47,\n  v: [\n    18, 13.45, 9.15, 7.91, 6.79, 4.8494, 3.6476, 3.2565, 1.8995, 1.3861, 0.971,\n    1.751, 1.4813, 1.494, 0.9013, 0.7599, 0.5335, 0.4651, 0.3116, 0.215, 0.12,\n    0.129, 0.134, 0.143, 0.143, 0.095, 0.092, 0.061, 0.03, 0.028, 0.033, 0.03,\n    0.039, 0.038, 0.032, 0.024, 0.008, -0.001, -0.002, -0,\n  ],\n};\n/** Its drift down, in reference px. */\nexport const BG_Y: Table = {\n  from: 47,\n  v: [\n    -0.68, -0.7, -0.14, 0.34, 0.36, 0.4344, 0.4116, 0.3287, 0.1941, -0.0261,\n    0.0106, -0.1763, -0.3804, -0.3697, -0.3417, -0.3645, -0.2931, -0.2826,\n    -0.2109, -0.209, -0.211, -0.19, -0.181, -0.158, -0.115, -0.055, -0.031,\n    0.01, 0.054, 0.071, 0.065, 0.069, 0.052, 0.044, 0.036, 0.024, 0.025, 0.015,\n    0.005, -0,\n  ],\n};\n/** Its blur, in the backdrop's own px. */\nexport const BG_BLUR: Table = {\n  from: 47,\n  v: [\n    14.91, 15.45, 14.33, 10.26, 6.93, 11.7455, 9.8469, 7.6187, 4.426, 3.187,\n    1.9011, 1.3233, 0.6, 0.3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0,\n  ],\n};\n/** The title's baseline. */\nexport const TITLE_Y: Table = {\n  from: 48,\n  v: [\n    212.158, 212.105, 212.085, 212.085, 212.085, 212.085, 212.085, 212.085,\n    212.085, 212.085, 212.043, 211.919, 211.741, 211.499, 211.188, 210.801,\n    210.33, 209.769, 209.094, 208.213, 207.02, 205.165, 201.343,\n  ],\n};\n/** How far below the title's baseline a letter still is, by frames since it began. */\nexport const LETTER_RISE: Table = {\n  from: 0,\n  v: [\n    2.104, 1.661, 1.283, 0.964, 0.7, 0.486, 0.317, 0.187, 0.091, 0.026, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n  ],\n};\n/** A letter's opacity, by frames since it began. */\nexport const LETTER_OPACITY: Table = {\n  from: 0,\n  v: [\n    0.372, 0.53, 0.64, 0.722, 0.791, 0.851, 0.892, 0.927, 0.953, 0.97, 0.981,\n    0.988, 0.995, 0.998, 0.998, 0.995, 0.997, 1, 1, 1, 1, 0.999, 0.995,\n  ],\n};\n/** The mark's centre line. */\nexport const MARK_Y: Table = {\n  from: 71,\n  v: [\n    204.337, 203.041, 202.271, 201.782, 201.431, 201.121, 200.837, 200.584,\n    200.368, 200.191, 200.046, 199.925, 199.819, 199.717, 199.612, 199.494,\n  ],\n};\n/** The mark's opacity. */\nexport const MARK_OPACITY: Table = {\n  from: 71,\n  v: [\n    0.642, 0.845, 0.916, 0.949, 0.975, 0.987, 0.998, 0.998, 0.997, 0.997, 1, 1,\n    1, 0.999, 1, 1,\n  ],\n};\n/** How far below its baseline a brand letter still is, by frames since it landed. */\nexport const BRAND_RISE: Table = {\n  from: 0,\n  v: [\n    3.059, 2.205, 1.602, 1.188, 0.904, 0.693, 0.528, 0.388, 0.255, 0.13, 0.02,\n    0, 0, 0,\n  ],\n};\n/** The two frames the chip spends opening: left, top, right, bottom, radius. */\nexport const OPENING: Record<\n  number,\n  readonly [number, number, number, number, number]\n> = {\n  47: [108.9, 50.8, 637.35, 347.11, 13.1],\n  48: [38.69, 14.06, 698.6, 383.87, 15.9],\n};\n\n/* ─────────────────────────────────────────────────────────────────────────\n   Measuring type\n   ───────────────────────────────────────────────────────────────────────── */\n\ntype Metrics = {\n  /** Advance of each prefix of the string, so `pre[i]` is where letter i starts. */\n  pre: number[];\n  /** Ascent and descent, as fractions of the size. */\n  asc: number;\n  desc: number;\n};\n\nconst FALLBACK = { asc: 0.9, desc: 0.22, char: 0.52 };\n\n/** Prefix advances with the tracking applied, at `size` px. */\nexport function measure(\n  text: string,\n  size: number,\n  weight: number,\n  tracking: number,\n  face: string,\n): Metrics {\n  const ctx =\n    typeof document === \"undefined\"\n      ? null\n      : document.createElement(\"canvas\").getContext(\"2d\");\n  if (!ctx) {\n    return {\n      pre: [...Array(text.length + 1).keys()].map(\n        (i) => i * size * (FALLBACK.char + tracking),\n      ),\n      asc: FALLBACK.asc,\n      desc: FALLBACK.desc,\n    };\n  }\n  ctx.font = `${weight} ${size}px ${face}`;\n  ctx.letterSpacing = `${tracking * size}px`;\n  const pre = [...Array(text.length + 1).keys()].map(\n    (i) => ctx.measureText(text.slice(0, i)).width,\n  );\n  const m = ctx.measureText(\"Hg\");\n  return {\n    pre,\n    asc: m.fontBoundingBoxAscent / size,\n    desc: m.fontBoundingBoxDescent / size,\n  };\n}\n\n/** Rewrite root-relative assets through staticFile everywhere but the Player. */\nfunction resolveSrc(src: string): string {\n  const isLocal = src.startsWith(\"/\") && !src.startsWith(\"//\");\n  if (!isLocal || getRemotionEnvironment().isPlayer) return src;\n  const base = staticFile(\"_\").slice(0, -2);\n  if (base && src.startsWith(`${base}/`)) return src;\n  try {\n    return staticFile(src.replace(/^\\/+/, \"\"));\n  } catch {\n    return src;\n  }\n}\n\n/* ─────────────────────────────────────────────────────────────────────────\n   The scene\n   ───────────────────────────────────────────────────────────────────────── */\n\nexport interface PortalIntroProps {\n  /** The words before the chip. They arrive one at a time. */\n  lead?: string;\n  /** The words after it, which arrive with the chip. */\n  trail?: string;\n  /** The picture the chip opens into. */\n  image?: string;\n  /** The chip's own picture, if it should differ from the backdrop. */\n  chipImage?: string;\n  /** The title typed over the picture. */\n  title?: string;\n  /** The name beside the mark. */\n  brand?: string;\n  /** The mark, drawn in `currentColor` in a MARK_SIZE box. Defaults to snapcn's. */\n  logo?: React.ReactNode;\n  /** Or the mark as an image URL, when it cannot be passed as an element. */\n  logoSrc?: string;\n  /** The ink of the title, the mark and the name over the picture. */\n  overlay?: string;\n  fontFamily?: string;\n  theme?: Partial<SnapCnTheme>;\n  mode?: \"light\" | \"dark\";\n  speed?: number;\n  className?: string;\n}\n\nexport function PortalIntro({\n  lead = \"your launch video\",\n  trail = \"in code\",\n  image = DEFAULT_IMAGE,\n  chipImage,\n  title = \"Introducing\",\n  brand = \"snapcn\",\n  logo,\n  logoSrc,\n  overlay = \"#ffffff\",\n  fontFamily,\n  theme,\n  mode = \"light\",\n  speed = 1,\n  className,\n}: PortalIntroProps) {\n  const frame = useCurrentFrame() * speed;\n  const { width, height } = useVideoConfig();\n  const t = useSnapCnTheme(theme, mode);\n  const face = resolveFont(fontFamily) ?? SANS;\n  const r = frame - LEAD;\n\n  const [handle] = useState(() => delayRender(\"portal-intro: font\"));\n  const [ready, setReady] = useState(false);\n  useEffect(() => {\n    loadFace()\n      .then(() => document.fonts.ready)\n      .finally(() => {\n        setReady(true);\n        continueRender(handle);\n      });\n  }, [handle]);\n\n  const leadWords = useMemo(() => lead.split(/\\s+/).filter(Boolean), [lead]);\n  const trailWords = useMemo(() => trail.split(/\\s+/).filter(Boolean), [trail]);\n\n  const type = useMemo(() => {\n    void ready;\n    const line = (words: string[]) => {\n      const text = words.join(\" \");\n      const m = measure(\n        `${text} `,\n        LINE_SIZE,\n        LINE_WEIGHT,\n        LINE_TRACKING,\n        face,\n      );\n      // Where each word starts: the prefix up to it, spaces included.\n      const starts: number[] = [];\n      let i = 0;\n      for (const w of words) {\n        starts.push(m.pre[i] ?? 0);\n        i += w.length + 1;\n      }\n      return {\n        starts,\n        width: m.pre[text.length] ?? 0,\n        withSpace: m.pre[text.length + 1] ?? 0,\n        asc: m.asc,\n        desc: m.desc,\n      };\n    };\n    return {\n      lead: line(leadWords),\n      trail: line(trailWords),\n      title: measure(title, TITLE_SIZE, TITLE_WEIGHT, TITLE_TRACKING, face),\n      brand: measure(brand, BRAND_SIZE, BRAND_WEIGHT, BRAND_TRACKING, face),\n    };\n  }, [ready, leadWords, trailWords, title, brand, face]);\n\n  // `cover`, so a 16:9 composition crops the frame rather than letterboxing it.\n  const k = Math.max(width / REF_W, height / REF_H);\n  const ink = t.foreground;\n  // The stage is one scaled layer, and Chrome snaps glyph baselines inside it —\n  // so the grid the type steps on is the stage's own pixel, not the device's.\n  const grid = [1, 0] as const;\n  const backdrop = resolveSrc(image);\n  const chipSrc = resolveSrc(chipImage ?? image);\n\n  const s = at(SCALE, Math.min(r, SECOND_LINE_TO));\n  const toX = (x: number) => PIVOT_X + s * (x - PIVOT_X);\n  const toY = (y: number) => PIVOT_Y + s * (y - PIVOT_Y);\n\n  const nodes: React.ReactNode[] = [];\n\n  if (r < FIRST_LINE_TO + 0.5) {\n    // The lead words alone, centred with their trailing space, drifting in.\n    const l = type.lead;\n    const x0 = CENTRE_A - l.withSpace / 2 + at(PAN, r);\n    leadWords.forEach((w, i) => {\n      const kk = r - STAGGER * i;\n      if (kk < WORD_OPACITY.from) return;\n      nodes.push(\n        <Glyphs\n          // biome-ignore lint/suspicious/noArrayIndexKey: a word's place in the line is its identity\n          key={`a${i}`}\n          text={w}\n          x={toX(x0 + (l.starts[i] ?? 0))}\n          baseline={toY(BASELINE + at(WORD_RISE, kk))}\n          size={LINE_SIZE}\n          scale={s}\n          weight={LINE_WEIGHT}\n          tracking={LINE_TRACKING}\n          asc={l.asc}\n          desc={l.desc}\n          color={ink}\n          opacity={at(WORD_OPACITY, kk)}\n        />,\n      );\n    });\n  }\n\n  // Where the chip is drawn, in reference px, while it sits in the line.\n  let chip: { l: number; t: number; w: number; h: number; r: number } | null =\n    null;\n  if (r >= FIRST_LINE_TO + 0.5 && r < SECOND_LINE_TO + 0.5) {\n    const l = type.lead;\n    const tr = type.trail;\n    const slot = at(SLOT, r);\n    const total = l.withSpace + slot + tr.width;\n    const x0 = CENTRE_B - total / 2;\n    const slotAt = x0 + l.withSpace;\n    const trailAt = slotAt + slot;\n    leadWords.forEach((w, i) => {\n      nodes.push(\n        <Glyphs\n          // biome-ignore lint/suspicious/noArrayIndexKey: a word's place in the line is its identity\n          key={`b${i}`}\n          text={w}\n          x={toX(x0 + (l.starts[i] ?? 0))}\n          baseline={toY(BASELINE)}\n          size={LINE_SIZE}\n          scale={s}\n          weight={LINE_WEIGHT}\n          tracking={LINE_TRACKING}\n          asc={l.asc}\n          desc={l.desc}\n          color={ink}\n        />,\n      );\n    });\n    trailWords.forEach((w, i) => {\n      nodes.push(\n        <Glyphs\n          // biome-ignore lint/suspicious/noArrayIndexKey: a word's place in the line is its identity\n          key={`c${i}`}\n          text={w}\n          x={toX(trailAt + (tr.starts[i] ?? 0))}\n          baseline={toY(BASELINE)}\n          size={LINE_SIZE}\n          scale={s}\n          weight={LINE_WEIGHT}\n          tracking={LINE_TRACKING}\n          asc={tr.asc}\n          desc={tr.desc}\n          color={ink}\n        />,\n      );\n    });\n    const cw = at(CHIP_W, r) * s;\n    const ch = at(CHIP_H, r) * s;\n    const cx = toX(slotAt + slot / 2 + at(CHIP_DX, r));\n    const cy = toY(PIVOT_Y + at(CHIP_DY, r));\n    chip = { l: cx - cw / 2, t: cy - ch / 2, w: cw, h: ch, r: CHIP_RADIUS * s };\n  }\n\n  // The opening: the two measured frames, then the whole frame.\n  let opening: {\n    l: number;\n    t: number;\n    w: number;\n    h: number;\n    r: number;\n  } | null = null;\n  if (r >= SECOND_LINE_TO + 0.5) {\n    const o = OPENING[Math.round(r)];\n    opening =\n      o && r < OPEN_AT - 0.5\n        ? { l: o[0], t: o[1], w: o[2] - o[0], h: o[3] - o[1], r: o[4] }\n        : { l: 0, t: 0, w: REF_W, h: REF_H, r: 0 };\n  }\n\n  const bgScale = at(BG_SCALE, r);\n  const bgBlur = at(BG_BLUR, r);\n\n  return (\n    <AbsoluteFill\n      className={className}\n      style={{ background: t.background, overflow: \"hidden\" }}\n    >\n      <AbsoluteFill\n        style={{\n          width: REF_W,\n          height: REF_H,\n          left: (width - REF_W * k) / 2,\n          top: (height - REF_H * k) / 2,\n          transform: `scale(${k})`,\n          transformOrigin: \"top left\",\n          background: t.background,\n          overflow: \"hidden\",\n          fontFamily: face,\n          textRendering: \"geometricPrecision\",\n        }}\n      >\n        {chip ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: chip.l,\n              top: chip.t,\n              width: chip.w,\n              height: chip.h,\n              borderRadius: chip.r,\n              overflow: \"hidden\",\n            }}\n          >\n            <Img\n              src={chipSrc}\n              style={{\n                width: \"100%\",\n                height: \"100%\",\n                objectFit: \"cover\",\n                transform: `scale(${at(CHIP_ZOOM, r)})`,\n              }}\n            />\n          </div>\n        ) : null}\n        {opening ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: opening.l,\n              top: opening.t,\n              width: opening.w,\n              height: opening.h,\n              borderRadius: opening.r,\n              overflow: \"hidden\",\n            }}\n          >\n            <div\n              style={{\n                position: \"absolute\",\n                left: -opening.l - (REF_W * (BLEED - 1)) / 2,\n                top: -opening.t - (REF_H * (BLEED - 1)) / 2,\n                width: REF_W * BLEED,\n                height: REF_H * BLEED,\n                transform: `translate(${at(BG_X, r)}px, ${at(BG_Y, r)}px) scale(${bgScale})`,\n                filter: bgBlur > 0.05 ? `blur(${bgBlur}px)` : undefined,\n              }}\n            >\n              <Img\n                src={backdrop}\n                style={{ width: \"100%\", height: \"100%\", objectFit: \"cover\" }}\n              />\n            </div>\n          </div>\n        ) : null}\n        {nodes}\n        {r >= TITLE_FROM && r < TITLE_TO + 0.5 ? (\n          <Title\n            text={title}\n            m={type.title}\n            r={r}\n            color={overlay}\n            grid={grid}\n          />\n        ) : null}\n        {r >= MARK_FROM ? (\n          <Brand\n            grid={grid}\n            text={brand}\n            m={type.brand}\n            r={r}\n            logo={\n              logo ??\n              (logoSrc ? (\n                <Img\n                  src={resolveSrc(logoSrc)}\n                  style={{\n                    width: \"100%\",\n                    height: \"100%\",\n                    objectFit: \"contain\",\n                  }}\n                />\n              ) : (\n                <SnapCnMark />\n              ))\n            }\n            color={overlay}\n          />\n        ) : null}\n      </AbsoluteFill>\n    </AbsoluteFill>\n  );\n}\n\n/* ─────────────────────────────────────────────────────────────────────────\n   Pieces\n   ───────────────────────────────────────────────────────────────────────── */\n\n/** One run of text, its origin on (x, baseline), scaled about that point. */\nfunction Glyphs({\n  text,\n  x,\n  baseline,\n  size,\n  scale = 1,\n  weight,\n  tracking,\n  asc,\n  desc,\n  color,\n  opacity = 1,\n  grid,\n}: {\n  text: string;\n  x: number;\n  baseline: number;\n  size: number;\n  scale?: number;\n  weight: number;\n  tracking: number;\n  asc: number;\n  desc: number;\n  color: string;\n  opacity?: number;\n  /**\n   * The pixel grid baselines snap to, as `[px per reference px, offset]`.\n   * Given, the run is drawn as two copies a grid pixel apart and blended —\n   * Chrome snaps a text baseline to a whole pixel, so a letter easing\n   * up by fractions of one would otherwise climb in visible one-pixel steps,\n   * each letter on its own frame: a tremble, not a rise.\n   */\n  grid?: readonly [number, number];\n}) {\n  // At `lineHeight: 1` the line box splits the leftover leading evenly, so the\n  // baseline sits this far below the box's top.\n  const rise = size * (asc + (1 - asc - desc) / 2);\n  if (opacity <= 0) return null;\n  if (grid && scale === 1) {\n    const [k, off] = grid;\n    const yd = off + (baseline - rise) * k;\n    const lo = Math.floor(yd);\n    const f = yd - lo;\n    const copy = (top: number, o: number) => (\n      <div\n        style={{\n          position: \"absolute\",\n          left: x,\n          top: (top - off) / k,\n          width: \"max-content\",\n          fontSize: size,\n          lineHeight: 1,\n          fontWeight: weight,\n          letterSpacing: `${tracking}em`,\n          whiteSpace: \"pre\",\n          color,\n          opacity: o,\n          mixBlendMode: \"plus-lighter\",\n        }}\n      >\n        {text}\n      </div>\n    );\n    return (\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          isolation: \"isolate\",\n          opacity,\n        }}\n      >\n        {copy(lo, 1 - f)}\n        {f > 0.001 ? copy(lo + 1, f) : null}\n      </div>\n    );\n  }\n  return (\n    <div\n      style={{\n        position: \"absolute\",\n        left: x,\n        top: baseline - rise,\n        width: \"max-content\",\n        transform: scale === 1 ? undefined : `scale(${scale})`,\n        transformOrigin: `0 ${rise}px`,\n        fontSize: size,\n        lineHeight: 1,\n        fontWeight: weight,\n        letterSpacing: `${tracking}em`,\n        whiteSpace: \"pre\",\n        color,\n        opacity,\n      }}\n    >\n      {text}\n    </div>\n  );\n}\n\n/** The title: one letter a frame, each fading up and settling as the word lifts. */\nfunction Title({\n  grid,\n  text,\n  m,\n  r,\n  color,\n}: {\n  grid: readonly [number, number];\n  text: string;\n  m: Metrics;\n  r: number;\n  color: string;\n}) {\n  const x0 = TITLE_CENTRE - (m.pre[text.length] ?? 0) / 2;\n  const base = at(TITLE_Y, r);\n  return (\n    <>\n      {[...text].map((c, i) => {\n        const kk = r - TITLE_FROM - i;\n        if (kk < 0 || c === \" \") return null;\n        return (\n          <Glyphs\n            // biome-ignore lint/suspicious/noArrayIndexKey: a letter's place is its identity\n            key={i}\n            text={c}\n            x={x0 + (m.pre[i] ?? 0)}\n            baseline={base + at(LETTER_RISE, kk)}\n            size={TITLE_SIZE}\n            weight={TITLE_WEIGHT}\n            tracking={TITLE_TRACKING}\n            asc={m.asc}\n            desc={m.desc}\n            color={color}\n            opacity={at(LETTER_OPACITY, kk)}\n            grid={grid}\n          />\n        );\n      })}\n    </>\n  );\n}\n\n/** The mark fades up rising; the name lands a letter every other frame beside it. */\nfunction Brand({\n  grid,\n  text,\n  m,\n  r,\n  logo,\n  color,\n}: {\n  grid: readonly [number, number];\n  text: string;\n  m: Metrics;\n  r: number;\n  logo: React.ReactNode;\n  color: string;\n}) {\n  const last = MARK_Y.from + MARK_Y.v.length - 1;\n  const y =\n    r <= last\n      ? at(MARK_Y, r)\n      : MARK_REST + (at(MARK_Y, last) - MARK_REST) * MARK_SETTLE ** (r - last);\n  const adv = m.pre[text.length] ?? 0;\n  const left = BRAND_CENTRE - (MARK_SIZE + BRAND_GAP + adv) / 2;\n  const textAt = left + MARK_SIZE + BRAND_GAP;\n  return (\n    <>\n      <div\n        style={{\n          position: \"absolute\",\n          left,\n          top: 0,\n          // A transform, not `top`: Chrome rounds a box's top edge to the device\n          // pixel, which would step the mark up a whole pixel at a time.\n          transform: `translateY(${y - MARK_SIZE / 2}px)`,\n          width: MARK_SIZE,\n          height: MARK_SIZE,\n          color,\n          opacity: at(MARK_OPACITY, r),\n          display: \"flex\",\n          alignItems: \"center\",\n          justifyContent: \"center\",\n        }}\n      >\n        {logo}\n      </div>\n      {[...text].map((c, i) => {\n        const kk = r - BRAND_FROM - BRAND_STAGGER * i;\n        if (kk < 0 || c === \" \") return null;\n        return (\n          <Glyphs\n            // biome-ignore lint/suspicious/noArrayIndexKey: a letter's place is its identity\n            key={i}\n            text={c}\n            x={textAt + (m.pre[i] ?? 0)}\n            baseline={y + BRAND_DROP + at(BRAND_RISE, kk)}\n            size={BRAND_SIZE}\n            weight={BRAND_WEIGHT}\n            tracking={BRAND_TRACKING}\n            asc={m.asc}\n            desc={m.desc}\n            color={color}\n            grid={grid}\n          />\n        );\n      })}\n    </>\n  );\n}\n\n/** snapcn's mark, on `currentColor`. */\nfunction SnapCnMark() {\n  return (\n    <svg\n      viewBox=\"0 0 464 409\"\n      width=\"100%\"\n      height=\"100%\"\n      fill=\"currentColor\"\n      aria-hidden\n    >\n      <g transform=\"translate(0,409) scale(0.1,-0.1)\">\n        <path d=\"M589 3805 c-167 -41 -305 -149 -380 -297 -60 -120 -59 -84 -59 -1239 0 -1004 1 -1059 19 -1112 48 -147 148 -226 331 -262 100 -20 127 -33 186 -87 53 -49 74 -109 74 -212 1 -121 42 -196 133 -244 l52 -27 980 -3 c883 -3 986 -1 1042 13 75 21 133 67 171 139 l27 51 3 315 c2 173 2 342 0 374 l-3 60 -31 -50 c-36 -59 -101 -115 -170 -146 l-49 -23 -810 -3 c-591 -2 -825 0 -865 8 -128 28 -258 121 -325 234 -65 110 -66 128 -63 826 l3 625 24 58 c44 111 147 210 270 259 l56 23 830 3 c809 2 831 2 895 -18 80 -25 149 -74 198 -142 l37 -52 3 334 c3 367 -3 418 -56 494 -30 44 -98 91 -152 106 -22 6 -457 10 -1175 9 -923 -1 -1151 -3 -1196 -14z M3800 2983 c-327 -196 -598 -361 -602 -367 -4 -6 -7 -254 -5 -550 l2 -540 145 -91 c80 -50 208 -130 285 -177 77 -47 283 -174 457 -282 174 -108 326 -196 337 -196 11 0 27 7 35 16 14 14 16 141 16 1254 0 781 -4 1248 -10 1264 -7 20 -16 26 -37 26 -18 -1 -232 -123 -623 -357z\" />\n      </g>\n    </svg>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/snap-cn/portal-intro.tsx"
    }
  ],
  "docs": "Docs and props: https://snapcn.dev/docs/scenes/portal-intro?ref=cli — pass mode=\"dark\" if you are rendering onto a dark frame; the picture, title and mark are props. — 82 Pro components too — charts, launch scenes, device shots: https://snapcn.dev/docs/pricing?ref=cli-docs",
  "type": "registry:component"
}
