{"version":3,"file":"VideoDetailPlayer.e8uc6LPW.mjs","names":["useState","useRef","useMemo","useCallback","startTransition"],"sources":["https:/framerusercontent.com/modules/ylrQwVxmzhBIjs6fa1vf/elOK0ycOmRqECSy8dYd6/VideoDetailPlayer.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef,useEffect,useMemo,useCallback,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const VIMEO_ORIGIN=\"https://player.vimeo.com\";/**\n * ForumSpace — Video Detail Player\n *\n * Poster-first inline player for video detail pages.\n * No iframe is mounted until the visitor clicks, so the Vimeo player\n * never blocks LCP on a page whose whole job is to load fast from an\n * emailed link.\n *\n * On sound: the click is a real user gesture, but the iframe is created\n * *after* it, and browsers don't reliably carry the gesture across to a\n * newly-mounted frame — so Vimeo starts muted. Passing muted=0 isn't\n * enough on its own. We also talk to the player over its postMessage API\n * once it reports ready, and explicitly set the volume. That runs close\n * enough to the original click that browsers honour it.\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n * @framerIntrinsicWidth 900\n * @framerIntrinsicHeight 506\n */export default function VideoDetailPlayer(props){const{videoURL=\"\",thumbnail,title=\"Video title\",style}=props;const[playing,setPlaying]=useState(false);const[hovered,setHovered]=useState(false);const containerRef=useRef(null);const iframeRef=useRef(null);const[containerWidth,setContainerWidth]=useState(900);useEffect(()=>{if(typeof window===\"undefined\")return;const el=containerRef.current;if(!el)return;startTransition(()=>setContainerWidth(el.offsetWidth));const RO=window.ResizeObserver;if(!RO)return;const ro=new RO(entries=>{for(const entry of entries){startTransition(()=>setContainerWidth(entry.contentRect.width));}});ro.observe(el);return()=>ro.disconnect();},[]);const isNarrow=containerWidth<600;const playSize=isNarrow?64:88;// Accepts vimeo.com/123, vimeo.com/123/abcdef, player.vimeo.com/video/123\n// and any of the ?share=copy junk the CMS URLs carry.\nconst embedUrl=useMemo(()=>{if(!videoURL)return null;const match=videoURL.match(/vimeo\\.com\\/(?:video\\/)?(\\d+)(?:\\/([a-zA-Z0-9]+))?/);if(!match)return null;const[,id,hash]=match;const params=new URLSearchParams({autoplay:\"1\",muted:\"0\",playsinline:\"1\",title:\"0\",byline:\"0\",portrait:\"0\",color:\"2F5D50\"});if(hash)params.set(\"h\",hash);return`https://player.vimeo.com/video/${id}?${params.toString()}`;},[videoURL]);// Send a command to the Vimeo player over postMessage.\nconst postToPlayer=useCallback((method,value)=>{const frame=iframeRef.current;if(!frame||!frame.contentWindow)return;const payload=value===undefined?{method}:{method,value};try{frame.contentWindow.postMessage(JSON.stringify(payload),VIMEO_ORIGIN);}catch{// Cross-origin hiccups are non-fatal — the video still plays,\n// just muted, and the viewer can unmute with the Vimeo control.\n}},[]);// Unmute as soon as the player reports ready, then again on first\n// playback. Vimeo emits `ready` once; some browsers apply the mute\n// slightly later, so the play event is a second chance.\nuseEffect(()=>{if(!playing||typeof window===\"undefined\")return;const unmute=()=>{postToPlayer(\"setMuted\",false);postToPlayer(\"setVolume\",1);};const onMessage=event=>{if(event.origin!==VIMEO_ORIGIN)return;let data=event.data;if(typeof data===\"string\"){try{data=JSON.parse(data);}catch{return;}}if(!data||typeof data!==\"object\")return;if(data.event===\"ready\"){// Subscribe to play so we can unmute a second time.\npostToPlayer(\"addEventListener\",\"play\");unmute();postToPlayer(\"play\");}if(data.event===\"play\"){unmute();}};window.addEventListener(\"message\",onMessage);return()=>window.removeEventListener(\"message\",onMessage);},[playing,postToPlayer]);const posterSrc=typeof thumbnail===\"string\"?thumbnail:thumbnail?.src||\"\";const posterSrcSet=typeof thumbnail===\"string\"?undefined:thumbnail?.srcSet;const posterAlt=typeof thumbnail===\"string\"?\"\":thumbnail?.alt||title;const play=useCallback(()=>{if(embedUrl)startTransition(()=>setPlaying(true));},[embedUrl]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\",width:\"100%\",aspectRatio:\"16 / 9\",borderRadius:16,overflow:\"hidden\",background:\"rgb(26, 26, 26)\",boxShadow:\"0px 4px 12px -2px rgba(0, 0, 0, 0.06)\"},children:playing&&embedUrl?/*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,src:embedUrl,title:title,allow:\"autoplay; fullscreen; picture-in-picture\",allowFullScreen:true,onLoad:()=>{// Belt and braces: some browsers never surface the\n// `ready` message, so fire the unmute on load too.\npostToPlayer(\"setMuted\",false);postToPlayer(\"setVolume\",1);postToPlayer(\"play\");},style:{width:\"100%\",height:\"100%\",border:\"none\",display:\"block\"}}):/*#__PURE__*/_jsxs(\"button\",{type:\"button\",onClick:play,onMouseEnter:()=>startTransition(()=>setHovered(true)),onMouseLeave:()=>startTransition(()=>setHovered(false)),\"aria-label\":`Play video: ${title}`,style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",padding:0,border:\"none\",background:\"transparent\",cursor:embedUrl?\"pointer\":\"default\",display:\"block\"},children:[posterSrc&&/*#__PURE__*/_jsx(\"img\",{src:posterSrc,srcSet:posterSrcSet,sizes:\"(max-width: 809px) 100vw, 900px\",alt:posterAlt,loading:\"eager\",fetchPriority:\"high\",style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\",transform:hovered?\"scale(1.02)\":\"scale(1)\",transition:\"transform 500ms ease\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,background:\"linear-gradient(to top, rgba(0,0,0,0.30) 0%, rgba(0,0,0,0.10) 55%, rgba(0,0,0,0.05) 100%)\",pointerEvents:\"none\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:\"50%\",left:\"50%\",transform:`translate(-50%, -50%) scale(${hovered?1.06:1})`,width:playSize,height:playSize,borderRadius:9999,background:\"rgba(253, 253, 253, 0.92)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",transition:\"transform 250ms ease\",pointerEvents:\"none\",boxShadow:\"0px 4px 20px rgba(0, 0, 0, 0.15)\"},children:/*#__PURE__*/_jsx(\"svg\",{width:isNarrow?26:34,height:isNarrow?26:34,viewBox:\"0 0 20 20\",xmlns:\"http://www.w3.org/2000/svg\",style:{marginLeft:2},\"aria-hidden\":\"true\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M7 4 L17 10 L7 16 Z\",fill:\"rgb(47, 93, 80)\",stroke:\"rgb(47, 93, 80)\",strokeWidth:\"2.5\",strokeLinejoin:\"round\"})})})]})});}addPropertyControls(VideoDetailPlayer,{videoURL:{type:ControlType.String,title:\"Vimeo URL\",placeholder:\"https://vimeo.com/...\",defaultValue:\"\"},thumbnail:{type:ControlType.ResponsiveImage,title:\"Poster\"},title:{type:ControlType.String,title:\"Title\",defaultValue:\"Video title\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"VideoDetailPlayer\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"506\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicWidth\":\"900\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./VideoDetailPlayer.map"],"mappings":"kOAmBG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,WAAS,GAAG,YAAU,QAAM,cAAc,SAAO,EAAW,CAAC,EAAQ,GAAYA,EAAS,EAAK,EAAO,CAAC,EAAQ,GAAYA,EAAS,EAAK,EAAQ,EAAaC,EAAO,IAAI,EAAQ,EAAUA,EAAO,IAAI,EAAO,CAAC,EAAe,GAAmBD,EAAS,GAAG,EAAE,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,EAAG,EAAa,QAAQ,GAAG,CAAC,EAAG,OAAO,MAAoB,EAAkB,EAAG,WAAW,CAAC,EAAE,IAAM,EAAG,EAAO,eAAe,GAAG,CAAC,EAAG,OAAO,IAAM,EAAG,IAAI,EAAG,GAAS,CAAC,IAAI,IAAM,KAAS,EAAS,MAAoB,EAAkB,EAAM,YAAY,KAAK,CAAC,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