{"version":3,"file":"ReelSoundControl.D8bw4CQn.mjs","names":["useRef","useState","useCallback","custom"],"sources":["https:/framerusercontent.com/modules/obmwKNJRrpDGo1KqVsHb/RObgn0bimpPl9HESjFMf/ReelSoundControl.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useCallback,useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function ReelSoundControl(props){const{arrow=\"↗\",mutedLabel=\"Unmute\",liveLabel=\"Mute\",color=\"#121212\",font={fontSize:\"12px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},gap=6,showOpacity=1,hideOpacity=0,fadeS=.2}=props;const activeIdsRef=useRef(new Set);const[isMuted,setIsMuted]=useState(true);const[isVisible,setIsVisible]=useState(false);const emitSoundChange=useCallback(nextMuted=>{if(typeof window===\"undefined\")return;window.__REEL_GLOBAL_MUTED__=nextMuted;window.dispatchEvent(new CustomEvent(\"reel-sound-change\",{detail:{muted:nextMuted}}));},[]);useEffect(()=>{if(typeof window===\"undefined\")return;if(typeof window.__REEL_GLOBAL_MUTED__!==\"boolean\"){window.__REEL_GLOBAL_MUTED__=true;}startTransition(()=>setIsMuted(Boolean(window.__REEL_GLOBAL_MUTED__)));const onSoundChange=event=>{const custom=event;const nextMuted=custom.detail?.muted;if(typeof nextMuted!==\"boolean\")return;window.__REEL_GLOBAL_MUTED__=nextMuted;startTransition(()=>setIsMuted(nextMuted));};const onVideoActive=event=>{const custom=event;const active=custom.detail?.active;const id=custom.detail?.id;if(typeof active!==\"boolean\")return;if(id){if(active){activeIdsRef.current.add(id);}else{activeIdsRef.current.delete(id);}startTransition(()=>setIsVisible(activeIdsRef.current.size>0));return;}startTransition(()=>setIsVisible(active));};window.addEventListener(\"reel-sound-change\",onSoundChange);window.addEventListener(\"reel-video-active\",onVideoActive);return()=>{window.removeEventListener(\"reel-sound-change\",onSoundChange);window.removeEventListener(\"reel-video-active\",onVideoActive);};},[]);const handleClick=useCallback(()=>{const nextMuted=!isMuted;startTransition(()=>setIsMuted(nextMuted));emitSoundChange(nextMuted);},[emitSoundChange,isMuted]);return /*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:handleClick,\"aria-label\":isMuted?\"Unmute reel videos\":\"Mute reel videos\",style:{position:\"relative\",width:\"max-content\",minWidth:\"max-content\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",gap,padding:0,margin:0,border:\"none\",outline:\"none\",background:\"transparent\",color,cursor:\"pointer\",opacity:isVisible?showOpacity:hideOpacity,pointerEvents:isVisible?\"auto\":\"none\",transition:`opacity ${fadeS}s ease`,fontFamily:font.fontFamily,fontSize:font.fontSize,fontWeight:font.fontWeight,fontStyle:font.fontStyle,lineHeight:font.lineHeight,letterSpacing:font.letterSpacing,textAlign:font.textAlign,WebkitTapHighlightColor:\"transparent\"},children:/*#__PURE__*/_jsx(\"span\",{children:isMuted?mutedLabel:liveLabel})});}addPropertyControls(ReelSoundControl,{arrow:{type:ControlType.String,title:\"Arrow\",defaultValue:\"↗\",hidden:()=>true},mutedLabel:{type:ControlType.String,title:\"Muted Label\",defaultValue:\"Unmute\"},liveLabel:{type:ControlType.String,title:\"Live Label\",defaultValue:\"Mute\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#121212\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"12px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}},gap:{type:ControlType.Number,title:\"Gap\",min:2,max:20,step:1,defaultValue:6},showOpacity:{type:ControlType.Number,title:\"Show Opacity\",min:0,max:1,step:.05,defaultValue:1},hideOpacity:{type:ControlType.Number,title:\"Hide Opacity\",min:0,max:1,step:.05,defaultValue:0},fadeS:{type:ControlType.Number,title:\"Fade (s)\",min:0,max:1,step:.05,defaultValue:.2}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ReelSoundControl\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ReelSoundControl.map"],"mappings":"oNAGG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,QAAM,IAAI,aAAW,SAAS,YAAU,OAAO,QAAM,UAAU,OAAK,CAAC,SAAS,OAAO,QAAQ,SAAS,cAAc,UAAU,WAAW,KAAK,EAAE,MAAI,EAAE,cAAY,EAAE,cAAY,EAAE,QAAM,IAAI,EAAY,EAAaA,EAAO,IAAI,GAAG,EAAO,CAAC,EAAQ,GAAYC,EAAS,EAAI,EAAO,CAAC,EAAU,GAAcA,EAAS,EAAK,EAAQ,EAAgBC,EAAY,GAAW,CAAW,IAAS,SAAmB,EAAO,sBAAsB,EAAU,EAAO,cAAc,IAAI,YAAY,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAkqC,OAAhqC,MAAc,CAAC,GAAU,IAAS,OAAY,OAAU,OAAO,EAAO,uBAAwB,YAAW,EAAO,sBAAsB,IAAM,MAAoB,EAAW,EAAQ,EAAO,qBAAsB,CAAC,EAAE,IAAM,EAAc,GAAO,CAAoB,IAAM,EAAUC,EAAO,QAAQ,MAAS,OAAO,GAAY,YAAiB,EAAO,sBAAsB,EAAU,MAAoB,EAAW,CAAS,CAAC,EAAE,EAAQ,EAAc,GAAO,CAAC,IAAM,EAAO,EAAY,EAAO,EAAO,QAAQ,OAAa,EAAG,EAAO,QAAQ,GAAM,UAAO,GAAS,UAAiB,IAAG,EAAG,CAAI,EAAQ,EAAa,QAAQ,IAAI,CAAE,EAAQ,EAAa,QAAQ,OAAO,CAAE,EAAG,MAAoB,EAAa,EAAa,QAAQ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