{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "transcribe-voice-message",
  "dependencies": [
    "motion",
    "react-icons"
  ],
  "files": [
    {
      "path": "src/components/watermelon-ui/transcribe-voice-message.tsx",
      "content": "import React, { useState, useEffect, useRef } from 'react';\nimport { motion, AnimatePresence } from 'motion/react';\nimport { TbMessageFilled, TbPlayerPauseFilled, TbPlayerPlayFilled } from 'react-icons/tb';\nimport { LuSun, LuMoon } from 'react-icons/lu';\n\ninterface VoiceMessageProps {\n    duration: number;\n    transcription: string;\n    waveformHeights?: number[];\n}\n\nconst DEFAULT_WAVEFORM = [\n    8, 12, 16, 12, 10, 18, 24, 16, 14, 20, 12, 16, 22, 18, 14, 10, 16, 24, 18, 14, 12, 10, 8, 12, 16, 14, 10\n];\n\nexport const TranscribeVoiceMessage: React.FC<VoiceMessageProps> = ({\n    duration: initialDuration,\n    transcription,\n    waveformHeights = DEFAULT_WAVEFORM\n}) => {\n    const [isPlaying, setIsPlaying] = useState(false);\n    const [currentTime, setCurrentTime] = useState(0);\n    const [showTranscription, setShowTranscription] = useState(false);\n    const [isDark, setIsDark] = useState(false);\n\n    const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n    useEffect(() => {\n        if (isPlaying && currentTime < initialDuration) {\n            timerRef.current = setInterval(() => {\n                setCurrentTime((prev) => {\n                    const next = prev + 0.1;\n                    if (next >= initialDuration) {\n                        setIsPlaying(false);\n                        return initialDuration;\n                    }\n                    return next;\n                });\n            }, 100);\n        } else {\n            if (timerRef.current) clearInterval(timerRef.current);\n        }\n\n        return () => {\n            if (timerRef.current) clearInterval(timerRef.current);\n        };\n    }, [isPlaying, currentTime, initialDuration]);\n\n    const handlePlayToggle = () => {\n        if (currentTime >= initialDuration) {\n            setCurrentTime(0);\n        }\n        setIsPlaying(!isPlaying);\n    };\n\n    const remainingTime = Math.ceil(initialDuration - currentTime);\n    const progressPercent = (currentTime / initialDuration) * 100;\n    const words = transcription.split(' ');\n    const revealedWordCount = Math.floor((currentTime / initialDuration) * words.length);\n    const visibleTranscription = words.slice(0, Math.max(1, revealedWordCount)).join(' ');\n\n    return (\n        <div className={`min-h-screen flex flex-col items-center justify-center p-6 transition-colors duration-500 ${isDark ? 'bg-[#0F0F12]' : 'bg-white'}`}>\n            \n            {/* Theme Toggle Button */}\n            <button \n                onClick={() => setIsDark(!isDark)}\n                className={`-mb-44 border p-3 rounded-2xl transition-all active:scale-95 ${isDark ? 'bg-[#1C1C21] text-yellow-400 border border-white/5' : 'bg-[#F6F5FA] text-gray-500 border border-black/5'}`}\n            >\n                {isDark ? <LuSun size={20} /> : <LuMoon size={20} />}\n            </button>\n\n            <div className=\"relative flex items-center gap-4 group\">\n\n                {/* Transcription Icon Toggle */}\n                <button title='transcription'\n                    onClick={() => setShowTranscription(!showTranscription)}\n                    className={`w-16 h-16 flex items-center justify-center rounded-full transition-all duration-300 ${\n                        showTranscription \n                            ? (isDark ? 'bg-transparent text-white border-2 border-white/20' : 'bg-transparent text-[#262629] border-2 border-[#e0e0e6]') \n                            : (isDark ? 'bg-[#1C1C21] text-white hover:bg-[#25252b]' : 'bg-[#F6F5FA] text-[#262629] hover:bg-gray-200')\n                    }`}\n                >\n                    <TbMessageFilled size={28} />\n                </button>\n\n                {/* Main Player Pill */}\n                <div className={`flex items-center gap-3 rounded-full px-4 py-3 min-w-[100px] shadow-sm transition-colors ${isDark ? 'bg-[#1C1C21]' : 'bg-[#F6F5FA]'}`}>\n                    <button\n                        onClick={handlePlayToggle}\n                        className={`w-8 h-8 flex items-center justify-center transition-all active:scale-90 ${isDark ? 'text-white' : 'text-[#262629]'}`}\n                    >\n                        {isPlaying ? (\n                            <TbPlayerPauseFilled size={24} />\n                        ) : (\n                            <TbPlayerPlayFilled size={24} className=\"ml-1\" />\n                        )}\n                    </button>\n\n                    {/* Waveform Visualization */}\n                    <div className=\"flex items-center gap-[3.5px] flex-1 h-10\">\n                        {waveformHeights.map((h, i) => {\n                            const barProgress = (i / waveformHeights.length) * 100;\n                            const isPlayed = barProgress < progressPercent;\n\n                            return (\n                                <motion.div\n                                    key={i}\n                                    initial={{ height: h * 0.7 }}\n                                    animate={{\n                                        height: h,\n                                        backgroundColor: isPlayed \n                                            ? (isDark ? '#FFFFFF' : '#111827') \n                                            : (isDark ? '#3F3F46' : '#ADACB8')\n                                    }}\n                                    transition={{ duration: 0.1 }}\n                                    className=\"w-[4px] rounded-full\"\n                                />\n                            );\n                        })}\n                    </div>\n\n                    {/* Timer */}\n                    <span className={`font-bold text-base w-6 text-right tabular-nums transition-colors ${isDark ? 'text-gray-400' : 'text-[#68676F]'}`}>\n                        {remainingTime}s\n                    </span>\n                </div>\n\n                {/* Transcription Bubble */}\n                <AnimatePresence>\n                    {showTranscription && (\n                        <motion.div\n                            initial={{ opacity: 0, scale: 0.8, y: 20 }}\n                            animate={{ opacity: 1, scale: 1, y: 0 }}\n                            exit={{ opacity: 0, scale: 0.8, y: 20 }}\n                            transition={{ type: 'spring', damping: 25, stiffness: 400 }}\n                            className=\"absolute bottom-[170%] left-0 z-10 pointer-events-none origin-bottom-left\"\n                        >\n                            <div className=\"relative\">\n                                {/* Main Bubble */}\n                                <div className={`rounded-[28px] p-6 px-5 max-w-[280px] shadow-sm border transition-colors ${isDark ? 'bg-[#1C1C21] border-white/5' : 'bg-[#F4F4F9] border-white/50'}`}>\n                                    <p className={`text-[18px] leading-[1.6] font-bold tracking-tight transition-colors ${isDark ? 'text-white' : 'text-[#29292E]'}`}>\n                                        {visibleTranscription}\n                                        <motion.span\n                                            animate={{ opacity: [1, 0] }}\n                                            transition={{ repeat: Infinity, duration: 0.8 }}\n                                            className={`inline-block w-[2px] h-[1.1em] ml-0.5 align-middle ${isDark ? 'bg-white/40' : 'bg-gray-400'}`}\n                                        />\n                                    </p>\n                                </div>\n\n                                {/* Speech Bubble Connectors*/}\n                                <div className=\"absolute -bottom-9 left-4 flex flex-col gap-1.5 items-center\">\n                                    <div className={`w-5 h-5 ml-4 rounded-full shadow-md transition-colors ${isDark ? 'bg-[#1C1C21]' : 'bg-[#F4F4F9]'}`} />\n                                    <div className={`w-3 h-3 rounded-full shadow-md transition-colors ${isDark ? 'bg-[#1C1C21]' : 'bg-[#F4F4F9]'}`} />\n                                </div>\n                            </div>\n                        </motion.div>\n                    )}\n                </AnimatePresence>\n            </div>\n        </div>\n    );\n};\n",
      "type": "registry:ui",
      "target": "components/ui/transcribe-voice-message.tsx"
    }
  ],
  "type": "registry:ui"
}
