{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sold-out",
  "title": "Sold Out",
  "description": "A stock counter races to zero, then a tilted chrome-gradient 'SOLD OUT' band slams across.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/sold-out/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Archivo\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: sans } = loadFont(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\nloadFont(\"italic\", { weights: [\"500\"], subsets: [\"latin\"] });\nconst { fontFamily: serif } = loadSerif(\"italic\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\n\nexport interface SoldOutProps {\n  /** Stock when the shot opens; it races down to zero. */\n  stock?: number;\n  /** Word after the counter. */\n  unit?: string;\n  /** Tag that flashes once the stock hits ten. */\n  warning?: string;\n  /** Set huge on the diagonal band at zero. */\n  stamp?: string;\n  /** Subline lead, in the grotesk. */\n  lead?: string;\n  /** Subline accent, in the serif italic. */\n  tail?: string;\n  /** Kept for the shared draft API; the band takes the \"chrome\" gradient. */\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\n// Archivo 500 (fontTools, wght 500, wdth 100): cap 0.686; figures 0.57em,\n// set in fixed 0.58em cells. \"LEFT\" 2.449em, side bearings 0.081 / 0.022.\n// Archivo 500 italic: \"SOLD OUT\" 5.068em.\nconst CAP = 0.686;\nconst CELL = 0.58;\nconst ADV: Record<string, number> = {\n  L: 0.552,\n  E: 0.674,\n  F: 0.611,\n  T: 0.612,\n  S: 0.67,\n  O: 0.785,\n  D: 0.731,\n  U: 0.728,\n  \" \": 0.205,\n  W: 0.938,\n  C: 0.725,\n  K: 0.677,\n};\nconst textEm = (s: string, track = 0) => {\n  const a = Array.from(s);\n  return (\n    a.reduce((w, ch) => w + (ADV[ch] ?? 0.66), 0) +\n    track * Math.max(0, a.length - 1)\n  );\n};\n\n// Beat sheet (30fps, speed 1, stock 128):\n//   0–9    \"128 LEFT\" punches in from 1.25× and a blur\n//  10–56   the reels race down to 10 (ease in-out), the units reel smears;\n//          the frame shakes harder the lower it gets\n//  56–86   ten hard ticks, 3 frames apart, each with a hit; LOW STOCK flashes\n//          and the figures turn red\n//  86–92   \"0 LEFT\" holds, trembling\n//  92–98   the SOLD OUT band slams across on the diagonal, big hit\n// 104–     subline rises; poster hold, the band's gradient drifts\nconst ENTER_LEN = 9;\nconst RACE_AT = 10;\nconst RACE_END = 56;\nconst TICK = 3;\nconst LOW = 10;\nconst ZERO_HOLD = 6;\nconst BAND_LEN = 6;\n\nconst SLAM = Easing.bezier(0.22, 1, 0.36, 1);\nconst RACE = Easing.bezier(0.55, 0, 0.35, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\n// gradients.sh \"chrome\" (bg #050203): #e0202e #ffd6b8 #4fe3f0.\nconst THEMES = {\n  dark: {\n    stage: \"#0A0A0B\",\n    ink: \"#F3F2EF\",\n    dim: \"#8A8990\",\n    red: \"#F0333F\",\n    tagInk: \"#F3F2EF\",\n    bandInk: \"#0A0A0B\",\n    flash: \"#F3F2EF\",\n    haze: \"#4a0d14\",\n  },\n  light: {\n    stage: \"#F5F4F0\",\n    ink: \"#121214\",\n    dim: \"#77766F\",\n    red: \"#D41E2C\",\n    tagInk: \"#F5F4F0\",\n    bandInk: \"#0A0A0B\",\n    flash: \"#121214\",\n    haze: \"#ffd6b8\",\n  },\n} as const;\nconst CHROME = [\"#e0202e\", \"#ff7a6a\", \"#ffd6b8\", \"#4fe3f0\"];\n\nfunction ramp(t: number, from: number, len: number) {\n  return interpolate(t, [from, from + len], [0, 1], CLAMP);\n}\n\n/** A short hit: up in 2 frames, eases back over 8. */\nfunction kick(d: number) {\n  if (d < 0) return 0;\n  if (d < 2) return d / 2;\n  const k = Math.max(0, 1 - (d - 2) / 8);\n  return k * k;\n}\n\n/** A decaying shake that dies in 7 frames. Deterministic. */\nfunction shake(d: number, amp: number, seed: number) {\n  if (d < 0 || d > 7) return { x: 0, y: 0 };\n  const k = (1 - d / 7) ** 2;\n  return {\n    x: amp * k * Math.sin(d * 2.7 + seed),\n    y: amp * 0.7 * k * Math.cos(d * 3.3 + seed * 1.7),\n  };\n}\n\n/** Continuous stock level at time t (reels read this). */\nfunction level(t: number, stock: number) {\n  const low = Math.min(LOW, stock);\n  if (t < RACE_AT) return stock;\n  if (t < RACE_END) {\n    const p = RACE((t - RACE_AT) / (RACE_END - RACE_AT));\n    return stock - (stock - low) * p;\n  }\n  // ten hard ticks: each one rolls its reel in 2 frames\n  const d = t - RACE_END;\n  const k = Math.floor(d / TICK);\n  const f = Math.min(1, (d - k * TICK) / 2);\n  const roll = SLAM(f);\n  return Math.max(0, low - k - (k < low ? roll : 0));\n}\n\n/** Reel position of the digit at place `p` (1, 10, 100…) for level v. */\nfunction reelPos(v: number, p: number) {\n  if (p === 1) return v;\n  const whole = Math.floor(v / p);\n  const rem = v - whole * p;\n  return whole + Math.max(0, rem - (p - 1));\n}\n\nexport function SoldOut({\n  stock = 128,\n  unit = \"LEFT\",\n  warning = \"LOW STOCK\",\n  stamp = \"SOLD OUT\",\n  lead = \"Restocking:\",\n  tail = \"every launch.\",\n  theme = \"dark\",\n  speed = 1,\n}: SoldOutProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = Math.min(W / 1280, H / 720);\n  const c = THEMES[theme];\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n  const total = Math.max(1, Math.round(stock));\n  const low = Math.min(LOW, total);\n  const zeroAt = RACE_END + low * TICK;\n  const bandAt = zeroAt + ZERO_HOLD;\n  const places = String(total).length;\n\n  const v = level(t, total);\n  const vel = Math.abs(level(t + 0.5, total) - level(t - 0.5, total));\n  const shown = Math.round(v);\n\n  // ── Layout: figures (huge) + unit (smaller, on the same baseline) ──\n  const unitRatio = 0.34;\n  const unitTrack = -0.01;\n  const unitEm = textEm(unit, unitTrack) - 0.081 - 0.022;\n  const gapEm = 0.16;\n  const fullEm = places * CELL + gapEm + unitEm * unitRatio;\n  const N = Math.min((0.86 * W) / fullEm, (0.62 * H) / CAP);\n  const capH = CAP * N;\n  const baseline = H * 0.53 + capH / 2;\n  const step = (CAP + 0.14) * N;\n\n  // places fade out as the stock drops below them; the group re-centres\n  let visible = 0;\n  const placeVis: number[] = [];\n  for (let i = 0; i < places; i++) {\n    const p = 10 ** (places - 1 - i);\n    const keep =\n      p === 1 ? 1 : interpolate(v, [p - 0.4, p + 0.05], [0, 1], CLAMP);\n    placeVis.push(SLAM(keep));\n    visible += SLAM(keep);\n  }\n  const groupW = visible * CELL * N + gapEm * N + unitEm * unitRatio * N;\n  const groupX = (W - groupW) / 2;\n  const unitX = groupX + visible * CELL * N + gapEm * N;\n\n  // ── Motion ──\n  const enter = SLAM(ramp(t, 0, ENTER_LEN));\n  const enterScale = 1.25 - 0.25 * enter;\n  const enterBlur = (1 - enter) * 14;\n  const isLow = v <= low + 0.01 && t >= RACE_END;\n  const lowAt = RACE_END;\n  // the tremble grows as the stock drains, then drops away under the band\n  const drain = 1 - v / total;\n  const band = SLAM(ramp(t, bandAt, BAND_LEN));\n  const tremble = 9 * u * drain ** 2.2 * (1 - ramp(t, bandAt, 4));\n  let sx =\n    tremble * (0.6 * Math.sin(t * 2.31 + 0.4) + 0.4 * Math.sin(t * 5.17 + 1.3));\n  let sy =\n    tremble * (0.6 * Math.cos(t * 2.83 + 2.1) + 0.4 * Math.sin(t * 4.41 + 0.2));\n  let bump = 0;\n  for (let k = 0; k < low; k++) {\n    const d = t - (RACE_END + k * TICK);\n    if (d < 0 || d > 12) continue;\n    const g = 0.5 + (0.7 * k) / Math.max(1, low - 1);\n    bump = Math.max(bump, 0.6 * g * kick(d));\n    const s = shake(d, 5 * u * g, k * 1.9);\n    sx += s.x;\n    sy += s.y;\n  }\n  const hitD = t - bandAt - BAND_LEN + 2;\n  bump = Math.max(bump, 1.5 * kick(hitD));\n  const s3 = shake(hitD, 16 * u, 3.3);\n  sx += s3.x;\n  sy += s3.y;\n  const camScale = 1 + 0.035 * bump;\n  const flash = interpolate(\n    t,\n    [bandAt + BAND_LEN - 2, bandAt + BAND_LEN - 1, bandAt + BAND_LEN + 3],\n    [0, 0.32, 0],\n    CLAMP,\n  );\n\n  const figInk = isLow ? c.red : c.ink;\n  const sinceLow = t - lowAt;\n  const tagOn =\n    t >= lowAt &&\n    t < bandAt + 4 &&\n    (sinceLow >= 24 || Math.floor(sinceLow / 4) % 2 === 0);\n  const tagPop = SLAM(ramp(t, lowAt, 4));\n  const behind = ramp(t, bandAt + 1, 8);\n\n  // ── Band ──\n  const angle = -11;\n  const bandH = 0.34 * H;\n  const bandLen = 1.5 * Math.hypot(W, H);\n  const bandX = -1.25 * bandLen * (1 - band);\n  const stampEm = textEm(stamp, -0.02);\n  const stampFs = Math.min((0.9 * W) / stampEm, (bandH * 0.78) / CAP);\n  const drift = ramp(t, bandAt, 70);\n  const bandGrad = `linear-gradient(90deg, ${CHROME[0]} ${34 - 8 * drift}%, ${CHROME[1]} ${44 - 6 * drift}%, ${CHROME[2]} ${58 - 4 * drift}%, ${CHROME[3]} ${74 - 4 * drift}%)`;\n  const rise = SLAM(ramp(t, bandAt + 12, 18));\n\n  const digit = (n: number) => ((n % 10) + 10) % 10;\n\n  return (\n    <AbsoluteFill style={{ background: c.stage, overflow: \"hidden\" }}>\n      {/* A low red haze creeps up as the stock runs out. */}\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          opacity: Math.max(0, drain - 0.4) * (theme === \"dark\" ? 0.9 : 0.7),\n          background: `radial-gradient(80% 60% at 50% 115%, ${c.haze} 0%, transparent 72%)`,\n        }}\n      />\n\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          transform: `translate(${sx}px, ${sy}px) scale(${camScale})`,\n          transformOrigin: \"50% 50%\",\n        }}\n      >\n        {/* The counter. */}\n        <svg\n          width={W}\n          height={H}\n          viewBox={`0 0 ${W} ${H}`}\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            overflow: \"visible\",\n            opacity: Math.min(ramp(t, 0, 2), 1 - 0.6 * behind),\n            transform: `scale(${enterScale * (1 - 0.04 * behind)})`,\n            transformOrigin: \"50% 52%\",\n            filter: enterBlur > 0.2 ? `blur(${enterBlur * u}px)` : undefined,\n          }}\n          role=\"img\"\n          aria-label={t >= bandAt ? stamp : `${shown} ${unit}`}\n        >\n          <defs>\n            <linearGradient id={`${uid}feather`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n              <stop offset=\"0\" stopColor=\"#fff\" stopOpacity={0} />\n              <stop offset=\"0.1\" stopColor=\"#fff\" />\n              <stop offset=\"0.9\" stopColor=\"#fff\" />\n              <stop offset=\"1\" stopColor=\"#fff\" stopOpacity={0} />\n            </linearGradient>\n            <mask\n              id={`${uid}win`}\n              maskUnits=\"userSpaceOnUse\"\n              x={0}\n              y={0}\n              width={W}\n              height={H}\n            >\n              <rect\n                x={0}\n                y={baseline - capH - 0.07 * N}\n                width={W}\n                height={capH + 0.14 * N}\n                fill={`url(#${uid}feather)`}\n              />\n            </mask>\n          </defs>\n\n          {/* LOW STOCK tag over the figures. */}\n          {tagOn ? (\n            <g\n              transform={`translate(${groupX} ${baseline - capH - 0.1 * H}) scale(${0.9 + 0.1 * tagPop})`}\n            >\n              <rect\n                x={0}\n                y={-0.062 * H}\n                width={\n                  (textEm(warning.toUpperCase(), 0.06) * 0.042 + 0.036) * H\n                }\n                height={0.074 * H}\n                fill={c.red}\n              />\n              <text\n                x={0.018 * H}\n                y={-0.009 * H}\n                fontFamily={sans}\n                fontWeight={500}\n                fontSize={0.042 * H}\n                fill={c.tagInk}\n                style={{ letterSpacing: \"0.06em\" }}\n              >\n                {warning.toUpperCase()}\n              </text>\n            </g>\n          ) : null}\n\n          <g\n            fontFamily={sans}\n            fontWeight={500}\n            fontSize={N}\n            textAnchor=\"middle\"\n            fill={figInk}\n            mask={`url(#${uid}win)`}\n            style={{ letterSpacing: \"-0.02em\" }}\n          >\n            {placeVis.map((vis, i) => {\n              const p = 10 ** (places - 1 - i);\n              const r = reelPos(v, p);\n              const base = Math.floor(r);\n              const f = r - base;\n              const x =\n                groupX +\n                (placeVis.slice(0, i).reduce((a, b) => a + b, 0) + 0.5) *\n                  CELL *\n                  N;\n              const placeVel = vel / p;\n              const sd = Math.min(0.22, placeVel * 0.06) * N;\n              if (vis < 0.01) return null;\n              return (\n                <g\n                  key={p}\n                  opacity={vis}\n                  transform={`translate(0 ${-f * step})`}\n                >\n                  <g filter={sd > 0.3 ? `url(#${uid}b${i})` : undefined}>\n                    <text x={x} y={baseline}>\n                      {digit(base)}\n                    </text>\n                    {f > 0.001 ? (\n                      <text x={x} y={baseline + step}>\n                        {digit(base + 1)}\n                      </text>\n                    ) : null}\n                  </g>\n                  <filter\n                    id={`${uid}b${i}`}\n                    filterUnits=\"userSpaceOnUse\"\n                    x={0}\n                    y={-H}\n                    width={W}\n                    height={3 * H}\n                  >\n                    <feGaussianBlur stdDeviation={`0 ${sd.toFixed(2)}`} />\n                  </filter>\n                </g>\n              );\n            })}\n          </g>\n          <text\n            x={unitX - 0.081 * N * unitRatio}\n            y={baseline}\n            fontFamily={sans}\n            fontWeight={500}\n            fontSize={N * unitRatio}\n            fill={figInk}\n            opacity={ramp(t, 2, 6)}\n            style={{ letterSpacing: `${unitTrack}em` }}\n          >\n            {unit}\n          </text>\n        </svg>\n\n        {/* The SOLD OUT band. */}\n        {t >= bandAt ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: W / 2 - bandLen / 2,\n              top: H * 0.5 - bandH / 2,\n              width: bandLen,\n              height: bandH,\n              transform: `rotate(${angle}deg) translateX(${bandX}px)`,\n              transformOrigin: \"50% 50%\",\n              background: bandGrad,\n              display: \"flex\",\n              alignItems: \"center\",\n              justifyContent: \"center\",\n              filter:\n                band < 0.98 ? `blur(${(1 - band) * 10 * u}px)` : undefined,\n            }}\n          >\n            <div\n              style={{\n                fontFamily: sans,\n                fontStyle: \"italic\",\n                fontWeight: 500,\n                fontSize: stampFs,\n                lineHeight: 1,\n                letterSpacing: \"-0.02em\",\n                color: c.bandInk,\n                whiteSpace: \"nowrap\",\n                transform: `translateY(${0.04 * stampFs}px)`,\n              }}\n            >\n              {stamp}\n            </div>\n          </div>\n        ) : null}\n      </div>\n\n      {/* Subline. */}\n      <div\n        style={{\n          position: \"absolute\",\n          left: 0,\n          right: 0,\n          top: H * 0.845,\n          display: \"flex\",\n          justifyContent: \"center\",\n          alignItems: \"baseline\",\n          gap: 0.012 * H,\n          color: c.ink,\n          lineHeight: 1,\n          whiteSpace: \"nowrap\",\n          opacity: rise,\n          transform: `translateY(${(1 - rise) * 14 * u}px)`,\n        }}\n      >\n        <span\n          style={{\n            fontFamily: sans,\n            fontWeight: 400,\n            fontSize: 0.05 * H,\n            letterSpacing: \"-0.02em\",\n          }}\n        >\n          {lead}\n        </span>\n        <span\n          style={{\n            fontFamily: serif,\n            fontStyle: \"italic\",\n            fontWeight: 400,\n            fontSize: 0.062 * H,\n            letterSpacing: \"-0.01em\",\n          }}\n        >\n          {tail}\n        </span>\n      </div>\n\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          background: c.flash,\n          opacity: flash,\n        }}\n      />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/sold-out.tsx"
    }
  ],
  "type": "registry:component"
}
