{"version":3,"file":"SoundOnClick.BJvhKgOp.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/KeEsJHTz7b98IPAbxOsn/gzAlkR3g3NSGwWpdQZFu/SoundOnClick.js"],"sourcesContent":["// Sound on Click Component - Plays different sounds for open/close menu states\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useRef,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Sound on Click Component\n * \n * Plays different sounds for open and close states.\n * Perfect for menu toggles with audio feedback.\n * Sounds continue playing even if component is unmounted.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function SoundOnClick(props){const{openSound=\"https://framerusercontent.com/assets/8w3IUatLX9a5JVJ6XPCVuHi94.mp3\",closeSound=\"https://framerusercontent.com/assets/8w3IUatLX9a5JVJ6XPCVuHi94.mp3\",initialState=false,volume=.5,backgroundColor=\"#000000\",openColor=\"#22CC66\",closeColor=\"#FF5588\",buttonText=\"\",openText=\"Open\",closeText=\"Close\",borderRadius=12,font,style}=props;const[isOpen,setIsOpen]=useState(initialState);const openAudioRef=useRef(null);const closeAudioRef=useRef(null);// Initialize audio elements\nuseEffect(()=>{if(typeof window===\"undefined\")return;// Create or reuse audio elements\nif(!openAudioRef.current){openAudioRef.current=new Audio(openSound);}else{openAudioRef.current.src=openSound;}if(!closeAudioRef.current){closeAudioRef.current=new Audio(closeSound);}else{closeAudioRef.current.src=closeSound;}if(openAudioRef.current)openAudioRef.current.volume=volume;if(closeAudioRef.current)closeAudioRef.current.volume=volume;// No cleanup - let sounds finish playing in background\n},[openSound,closeSound,volume]);// Update volume when it changes\nuseEffect(()=>{if(openAudioRef.current)openAudioRef.current.volume=volume;if(closeAudioRef.current)closeAudioRef.current.volume=volume;},[volume]);const handleClick=()=>{const newState=!isOpen;// Play appropriate sound\nif(typeof window!==\"undefined\"){const audioToPlay=newState?openAudioRef.current:closeAudioRef.current;if(audioToPlay){audioToPlay.currentTime=0;audioToPlay.play().catch(error=>{console.warn(\"Audio playback failed:\",error);});}}startTransition(()=>{setIsOpen(newState);});};const displayText=buttonText||(isOpen?openText:closeText);const currentColor=isOpen?openColor:closeColor;return /*#__PURE__*/_jsx(\"div\",{onClick:handleClick,style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",cursor:\"pointer\"},\"aria-pressed\":isOpen,\"aria-label\":`Toggle menu: ${isOpen?\"open\":\"closed\"}`});}addPropertyControls(SoundOnClick,{openSound:{type:ControlType.File,title:\"Open Sound\",allowedFileTypes:[\"mp3\",\"wav\",\"ogg\"]},closeSound:{type:ControlType.File,title:\"Close Sound\",allowedFileTypes:[\"mp3\",\"wav\",\"ogg\"]},volume:{type:ControlType.Number,title:\"Volume\",defaultValue:.5,min:0,max:1,step:.1},initialState:{type:ControlType.Boolean,title:\"Initial State\",defaultValue:false,enabledTitle:\"Open\",disabledTitle:\"Closed\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SoundOnClick\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SoundOnClick.map"],"mappings":"8MAUG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,YAAU,qEAAqE,aAAW,qEAAqE,eAAa,GAAM,SAAO,GAAG,kBAAgB,UAAU,YAAU,UAAU,aAAW,UAAU,aAAW,GAAG,WAAS,OAAO,YAAU,QAAQ,eAAa,GAAG,OAAK,SAAO,EAAW,CAAC,EAAO,GAAWA,EAAS,CAAY,EAAQ,EAAaC,EAAO,IAAI,EAAQ,EAAcA,EAAO,IAAI,EAK1H,OAJ1X,MAAc,CAAW,IAAS,SAC9B,EAAa,QAAyD,EAAa,QAAQ,IAAI,EAAzE,EAAa,QAAQ,IAAI,MAAM,CA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