{"version":3,"file":"StreamBackground.AVZi3ab9.mjs","names":["useRef","useState","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","window","ce","init_jsx_runtime","c","p","_e","de","init_framer_BpuvUAiZ","RenderTarget","addPropertyControls","ControlType","StreamBackground","props","boxRef","size","setSize","reduced","setReduced","ready","setReady","inView","setInView","isCanvas","id","videoId","code","customerCode","el","update","r","ro","io","e","es","mq","style","base","poster","posterTime","src","vw","w","vh","RATIO","h","playVideo","k","overlay","narrow","a","n","sideShade","topShade","bottomShade","brandTint","radius","init_StreamBackground"],"sources":["https:/framerusercontent.com/modules/4hZh8it2PCmUfw7iAJmt/eoV0Cwalw42KWF1GM3Q4/StreamBackground.js"],"sourcesContent":["// Arthur's request: the /events hero should have a background video of the team at work instead of the flat glow.\n// Muted, looping Cloudflare Stream video that always covers its frame, with a dark brand overlay so the\n// headline stays readable. Shows the poster still on the canvas, for reduced-motion visitors and while loading.\n// With no video ID it renders nothing, so whatever sits underneath (the current glow) shows through.\n// 29 Nov 2026, PHONE FREEZE FIX (see VideoBits.tsx): the background player now only runs while the hero is on\n// screen. Once you scroll past it the player is removed (the still stays), so it isn't decoding video in the\n// background while the phone is playing previews further down. It comes back when you scroll up.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";const RATIO=16/9;/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function StreamBackground(props){const{videoId,customerCode,posterTime,overlay,radius,style}=props;const boxRef=useRef(null);const[size,setSize]=useState({w:0,h:0});const[reduced,setReduced]=useState(false);const[ready,setReady]=useState(false);const[inView,setInView]=useState(true);const isCanvas=RenderTarget.current()===RenderTarget.canvas;const id=(videoId||\"\").trim();const code=(customerCode||\"\").trim();useEffect(()=>{if(!boxRef.current||typeof ResizeObserver===\"undefined\")return;const el=boxRef.current;const update=()=>{const r=el.getBoundingClientRect();setSize({w:r.width,h:r.height});};update();const ro=new ResizeObserver(update);ro.observe(el);return()=>ro.disconnect();},[]);useEffect(()=>{const el=boxRef.current;if(!el||typeof IntersectionObserver===\"undefined\")return;const io=new IntersectionObserver(es=>{const e=es[es.length-1];setInView(e.isIntersecting);if(!e.isIntersecting)setReady(false);},{rootMargin:\"50px 0px\"});io.observe(el);return()=>io.disconnect();},[]);useEffect(()=>{if(typeof window===\"undefined\"||!window.matchMedia)return;const mq=window.matchMedia(\"(prefers-reduced-motion: reduce)\");const update=()=>setReduced(mq.matches);update();if(mq.addEventListener)mq.addEventListener(\"change\",update);return()=>{if(mq.removeEventListener)mq.removeEventListener(\"change\",update);};},[]);if(!id||!code){return /*#__PURE__*/_jsx(\"div\",{ref:boxRef,style:{width:\"100%\",height:\"100%\",...style}});}const base=`https://customer-${code}.cloudflarestream.com/${id}`;const poster=`${base}/thumbnails/thumbnail.jpg?time=${Math.max(0,posterTime||0)}s&height=1080`;const src=`${base}/iframe?muted=true&autoplay=true&loop=true&controls=false&preload=auto`+`&poster=${encodeURIComponent(poster)}`;// Size the 16:9 player so it always covers the frame, like object-fit: cover.\nconst{w,h}=size;let vw=w;let vh=w/RATIO;if(vh<h){vh=h;vw=h*RATIO;}vw=Math.ceil(vw)+4;vh=Math.ceil(vh)+4;const playVideo=!isCanvas&&!reduced&&w>0&&inView;const k=Math.min(1,Math.max(0,overlay));const narrow=w>0&&w<720;const a=n=>(n*k).toFixed(3);// Darker on the text side (left), lighter where the action sits (right); flat and darker on phones.\nconst sideShade=narrow?`linear-gradient(180deg, rgba(12,10,20,${a(.62)}) 0%, rgba(12,10,20,${a(.78)}) 100%)`:`linear-gradient(90deg, rgba(12,10,20,${a(.9)}) 0%, rgba(12,10,20,${a(.66)}) 45%, rgba(12,10,20,${a(.32)}) 100%)`;const topShade=`linear-gradient(180deg, rgba(12,10,20,${a(.6)}) 0%, rgba(12,10,20,0) 22%)`;const bottomShade=`linear-gradient(0deg, rgba(12,10,20,${a(.55)}) 0%, rgba(12,10,20,0) 35%)`;const brandTint=`radial-gradient(110% 85% at 88% 105%, rgba(121,73,252,${a(.5)}) 0%, rgba(121,73,252,0) 62%)`;return /*#__PURE__*/_jsxs(\"div\",{ref:boxRef,\"aria-hidden\":\"true\",style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",borderRadius:radius,background:\"#0e0c14\",pointerEvents:\"none\",...style},children:[/*#__PURE__*/_jsx(\"img\",{src:poster,alt:\"\",style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\"}}),playVideo&&/*#__PURE__*/_jsx(\"iframe\",{src:src,title:\"\",tabIndex:-1,allow:\"autoplay; encrypted-media\",onLoad:()=>setTimeout(()=>setReady(true),600),style:{position:\"absolute\",top:\"50%\",left:\"50%\",width:vw,height:vh,transform:\"translate(-50%, -50%)\",border:0,opacity:ready?1:0,transition:\"opacity 700ms ease\",pointerEvents:\"none\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,background:[topShade,bottomShade,brandTint,sideShade].join(\", \")}})]});}StreamBackground.defaultProps={videoId:\"\",customerCode:\"but5jhvwjvglsn3q\",posterTime:1,overlay:1,radius:\"0px 0px 12px 12px\"};addPropertyControls(StreamBackground,{videoId:{type:ControlType.String,title:\"Stream video ID\",defaultValue:\"\"},customerCode:{type:ControlType.String,title:\"Customer code\",defaultValue:\"but5jhvwjvglsn3q\"},posterTime:{type:ControlType.Number,title:\"Poster at\",defaultValue:1,min:0,max:600,step:.5,unit:\"s\",displayStepper:true},overlay:{type:ControlType.Number,title:\"Overlay\",defaultValue:1,min:0,max:1,step:.05},radius:{type:ControlType.String,title:\"Radius\",defaultValue:\"0px 0px 12px 12px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"StreamBackground\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\"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