{"version":3,"file":"AudioToggleButton.BfB5wf3K.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/nO328346NmmDeS42kGq4/skEfbFzY7p6aufNk6kBx/AudioToggleButton.js"],"sourcesContent":["// Interactive audio toggle button with volume icon that plays/stops MP3 on click\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";/**\n * Interactive audio toggle button with volume icon\n * Plays/stops audio on click with smooth icon transition\n *\n * @framerIntrinsicWidth 48\n * @framerIntrinsicHeight 48\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function AudioToggleButton(props){const{audioFile=\"https://framerusercontent.com/assets/8w3IUatLX9a5JVJ6XPCVuHi94.mp3\",iconColor=\"#000000\",iconColorOff=\"#CCCCCC\",backgroundColor=\"#FFFFFF\",backgroundColorOff=\"#F5F5F5\",volume=.7,loop=false,autoPlay=false}=props;const[isPlaying,setIsPlaying]=useState(false);const audioRef=useRef(null);const hasAutoPlayed=useRef(false);useEffect(()=>{if(typeof window===\"undefined\")return;if(!audioRef.current){audioRef.current=new Audio(audioFile);}const audio=audioRef.current;// Update audio properties\nif(audio.src!==audioFile){audio.src=audioFile;}audio.volume=Math.max(0,Math.min(1,volume));audio.loop=loop;const handleEnded=()=>{if(!loop){startTransition(()=>setIsPlaying(false));}};audio.addEventListener(\"ended\",handleEnded);// Auto-play logic\nif(autoPlay&&!hasAutoPlayed.current){hasAutoPlayed.current=true;audio.currentTime=0;startTransition(()=>setIsPlaying(true));const playPromise=audio.play();if(playPromise!==undefined){playPromise.catch(error=>{console.warn(\"Autoplay prevented:\",error);startTransition(()=>setIsPlaying(false));});}}return()=>{audio.removeEventListener(\"ended\",handleEnded);};},[audioFile,volume,loop,autoPlay]);const handleToggle=()=>{if(!audioRef.current)return;if(isPlaying){audioRef.current.pause();audioRef.current.currentTime=0;startTransition(()=>setIsPlaying(false));}else{audioRef.current.currentTime=0;audioRef.current.play().then(()=>{startTransition(()=>setIsPlaying(true));}).catch(error=>{console.error(\"Playback failed:\",error);});}};const currentIconColor=isPlaying?iconColor:iconColorOff;const currentBgColor=isPlaying?backgroundColor:backgroundColorOff;return /*#__PURE__*/_jsx(motion.button,{onClick:handleToggle,style:{width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",border:\"none\",borderRadius:8,cursor:\"pointer\",padding:0,backgroundColor:currentBgColor,transition:\"background-color 0.3s ease\"},whileHover:{scale:1.05},whileTap:{scale:.95},\"aria-label\":isPlaying?\"Mute audio\":\"Play audio\",\"aria-pressed\":isPlaying,children:/*#__PURE__*/_jsx(motion.div,{initial:false,animate:{scale:isPlaying?1:.9,opacity:isPlaying?1:.7},transition:{duration:.3,ease:\"easeInOut\"},style:{width:\"60%\",height:\"60%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:isPlaying?/*#__PURE__*/_jsxs(\"svg\",{width:\"100%\",height:\"100%\",viewBox:\"0 0 24 24\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M11 5L6 9H2V15H6L11 19V5Z\",fill:currentIconColor,stroke:currentIconColor,strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\"}),/*#__PURE__*/_jsx(motion.path,{d:\"M15.54 8.46C16.4774 9.39764 17.0039 10.6692 17.0039 11.995C17.0039 13.3208 16.4774 14.5924 15.54 15.53\",stroke:currentIconColor,strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:1},transition:{duration:.3,delay:.1}}),/*#__PURE__*/_jsx(motion.path,{d:\"M18.07 5.93C19.9447 7.80528 20.9979 10.3462 20.9979 13C20.9979 15.6538 19.9447 18.1947 18.07 20.07\",stroke:currentIconColor,strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:1},transition:{duration:.3,delay:.2}})]}):/*#__PURE__*/_jsxs(\"svg\",{width:\"100%\",height:\"100%\",viewBox:\"0 0 24 24\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M11 5L6 9H2V15H6L11 19V5Z\",fill:currentIconColor,stroke:currentIconColor,strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\"}),/*#__PURE__*/_jsx(motion.line,{x1:\"23\",y1:\"9\",x2:\"17\",y2:\"15\",stroke:currentIconColor,strokeWidth:\"2\",strokeLinecap:\"round\",initial:{pathLength:0},animate:{pathLength:1},transition:{duration:.3}}),/*#__PURE__*/_jsx(motion.line,{x1:\"17\",y1:\"9\",x2:\"23\",y2:\"15\",stroke:currentIconColor,strokeWidth:\"2\",strokeLinecap:\"round\",initial:{pathLength:0},animate:{pathLength:1},transition:{duration:.3}})]})})});}addPropertyControls(AudioToggleButton,{autoPlay:{type:ControlType.Boolean,title:\"Auto Play\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},audioFile:{type:ControlType.File,title:\"Audio File\",allowedFileTypes:[\"mp3\",\"wav\",\"ogg\"]},iconColor:{type:ControlType.Color,title:\"Icon Color (On)\",defaultValue:\"#000000\"},iconColorOff:{type:ControlType.Color,title:\"Icon Color (Off)\",defaultValue:\"#CCCCCC\"},backgroundColor:{type:ControlType.Color,title:\"Background (On)\",defaultValue:\"#FFFFFF\"},backgroundColorOff:{type:ControlType.Color,title:\"Background (Off)\",defaultValue:\"#F5F5F5\"},volume:{type:ControlType.Number,title:\"Volume\",defaultValue:.7,min:0,max:1,step:.1,displayStepper:false},loop:{type:ControlType.Boolean,title:\"Loop Audio\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AudioToggleButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicHeight\":\"48\",\"framerIntrinsicWidth\":\"48\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AudioToggleButton.map"],"mappings":"gQAUG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,YAAU,qEAAqE,YAAU,UAAU,eAAa,UAAU,kBAAgB,UAAU,qBAAmB,UAAU,SAAO,GAAG,OAAK,GAAM,WAAS,IAAO,EAAW,CAAC,EAAU,GAAcA,EAAS,EAAK,EAAQ,EAASC,EAAO,IAAI,EAAQ,EAAcA,EAAO,EAAK,EAAE,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,AAAsB,EAAS,UAAQ,IAAI,MAAM,CAAS,EAAG,IAAM,EAAM,EAAS,QACtgB,EAAM,MAAM,IAAW,EAAM,IAAI,GAAW,EAAM,OAAO,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,CAAM,CAAC,EAAE,EAAM,KAAK,EAAK,IAAM,MAAgB,CAAK,GAAM,MAAoB,EAAa,EAAK,CAAC,CAAG,EACtL,GADwL,EAAM,iBAAiB,QAAQ,CAAW,EAC/N,GAAU,CAAC,EAAc,QAAQ,CAAC,EAAc,QAAQ,GAAK,EAAM,YAAY,EAAE,MAAoB,EAAa,EAAI,CAAC,EAAE,IAAM,EAAY,EAAM,KAAK,EAAK,IAAc,IAAA,IAAW,EAAY,MAAM,GAAO,CAAC,QAAQ,KAAK,sBAAsB,CAAK,EAAE,MAAoB,EAAa,EAAK,CAAC,CAAE,CAAC,CAAG,CAAC,UAAU,CAAC,EAAM,oBAAoB,QAAQ,CAAW,CAAE,CAAE,EAAE,CAAC,EAAU,EAAO,EAAK,CAAQ,CAAC,EAAE,IAAM,MAAiB,CAAK,EAAS,UAAkB,GAAW,EAAS,QAAQ,MAAM,EAAE,EAAS,QAAQ,YAA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