{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "caption-pill-karaoke",
  "title": "Caption Pill Karaoke",
  "description": "Karaoke-style captions where each word sits inside a pill-shaped background.",
  "dependencies": [
    "@editframe/react"
  ],
  "files": [
    {
      "path": "registry/bases/editframe/components/caption-pill-karaoke/index.tsx",
      "content": "\"use client\";\n\nimport { Timegroup } from \"@editframe/react\";\nimport type { CSSProperties } from \"react\";\n\nexport interface CaptionWord {\n  text: string;\n  start: number;\n  end: number;\n}\n\nexport interface CaptionPillKaraokeProps {\n  words?: CaptionWord[];\n  wordsPerSegment?: number;\n  activeColor?: string;\n  dimColor?: string;\n  pillColor?: string;\n  fontSize?: number;\n  fontWeight?: number | string;\n  background?: string;\n  speed?: number;\n  fps?: number;\n  durationInFrames?: number;\n  width?: number;\n  height?: number;\n  className?: string;\n}\n\nconst DEFAULT_WORDS: CaptionWord[] = [\n  { end: 0.35, start: 0, text: \"Every\" },\n  { end: 0.65, start: 0.35, text: \"great\" },\n  { end: 1, start: 0.65, text: \"video\" },\n  { end: 1.45, start: 1.1, text: \"starts\" },\n  { end: 1.65, start: 1.45, text: \"with\" },\n  { end: 1.8, start: 1.65, text: \"a\" },\n  { end: 2.15, start: 1.8, text: \"single\" },\n  { end: 2.7, start: 2.15, text: \"frame.\" },\n  { end: 3.2, start: 3, text: \"No\" },\n  { end: 3.9, start: 3.2, text: \"timelines.\" },\n  { end: 4.2, start: 4, text: \"No\" },\n  { end: 4.5, start: 4.2, text: \"drag\" },\n  { end: 4.65, start: 4.5, text: \"and\" },\n  { end: 5.1, start: 4.65, text: \"drop.\" },\n  { end: 5.55, start: 5.3, text: \"Just\" },\n  { end: 6, start: 5.55, text: \"code.\" },\n];\n\nexport const CaptionPillKaraoke = ({\n  words = DEFAULT_WORDS,\n  wordsPerSegment = 6,\n  activeColor = \"#1a1a1a\",\n  dimColor = \"#a6a6a6\",\n  pillColor = \"#e7e5e7\",\n  fontSize = 60,\n  fontWeight = 700,\n  background = \"#0a0a0a\",\n  speed = 1,\n  fps = 30,\n  durationInFrames = 180,\n  width = 1280,\n  height = 720,\n  className,\n}: CaptionPillKaraokeProps) => {\n  const safeSpeed = Math.max(0.01, speed);\n  const durationMs = (durationInFrames / fps) * 1000;\n\n  const segments = [];\n  for (let i = 0; i < words.length; i += wordsPerSegment) {\n    const segWords = words.slice(i, i + wordsPerSegment);\n    segments.push({\n      endMs: ((segWords.at(-1)?.end ?? 0) * 1000) / safeSpeed + 180,\n      startMs: (segWords[0].start * 1000) / safeSpeed,\n      words: segWords,\n    });\n  }\n\n  const containerStyle: CSSProperties = {\n    background,\n    height,\n    overflow: \"hidden\",\n    position: \"relative\",\n    width,\n  };\n\n  return (\n    <Timegroup\n      className={className}\n      duration={`${durationMs}ms`}\n      mode=\"fixed\"\n      style={containerStyle}\n    >\n      <>\n        <style>{`\n          @keyframes framecn-pk-seg-in {\n            from { opacity: 0; transform: translateY(10px) scale(0.97); }\n            to   { opacity: 1; transform: translateY(0) scale(1); }\n          }\n          @keyframes framecn-pk-seg-out {\n            from { opacity: 1; }\n            to   { opacity: 0; }\n          }\n          @keyframes framecn-pk-word-active {\n            0%, 100% { color: ${dimColor}; }\n            8%, 92%  { color: ${activeColor}; }\n          }\n        `}</style>\n        <div\n          style={{\n            bottom: Math.round(height * 0.12),\n            display: \"flex\",\n            justifyContent: \"center\",\n            left: 0,\n            position: \"absolute\",\n            right: 0,\n          }}\n        >\n          {segments.map((seg, si) => (\n            <div\n              key={si}\n              style={{\n                animation: [\n                  `framecn-pk-seg-in 150ms cubic-bezier(0.16, 1, 0.3, 1) ${seg.startMs}ms both`,\n                  `framecn-pk-seg-out 100ms ease-in ${seg.endMs}ms forwards`,\n                ].join(\", \"),\n                opacity: 0,\n                position: \"absolute\",\n              }}\n            >\n              <div\n                style={{\n                  background: pillColor,\n                  borderRadius: 22,\n                  boxShadow: \"0 2px 12px rgba(0,0,0,0.15)\",\n                  display: \"flex\",\n                  flexWrap: \"wrap\",\n                  gap: \"0.3em\",\n                  justifyContent: \"center\",\n                  maxWidth: width - 160,\n                  padding: \"18px 56px 20px\",\n                }}\n              >\n                {seg.words.map((word, wi) => {\n                  const wordStartMs = (word.start * 1000) / safeSpeed;\n                  const wordDurationMs = Math.max(\n                    150,\n                    ((word.end - word.start) * 1000) / safeSpeed\n                  );\n                  return (\n                    <span\n                      key={wi}\n                      style={{\n                        animation: `framecn-pk-word-active ${wordDurationMs}ms ease-in-out ${wordStartMs}ms both`,\n                        color: dimColor,\n                        fontFamily:\n                          \"'Poppins', var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n                        fontSize,\n                        fontWeight,\n                        letterSpacing: 0,\n                        lineHeight: 1.2,\n                      }}\n                    >\n                      {word.text}\n                    </span>\n                  );\n                })}\n              </div>\n            </div>\n          ))}\n        </div>\n      </>\n    </Timegroup>\n  );\n};\n",
      "type": "registry:component",
      "target": "components/framecn/caption-pill-karaoke.tsx"
    }
  ],
  "type": "registry:component"
}