{"version":3,"file":"ParallaxMedia.DLSrmjo3.mjs","names":["React.useRef","React.useState"],"sources":["https:/framerusercontent.com/modules/k8C5LbGNn8J9MxgtVxVq/lGOWFDpi4B40a0LgKJJa/ParallaxMedia.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{motion,useScroll,useTransform,addPropertyControls,ControlType,useIsStaticRenderer,RenderTarget}from\"framer\";/* ----------------------------------------------------------------\n *  Helpers\n * ---------------------------------------------------------------- */const clamp=(v,min,max)=>Math.max(min,Math.min(max,v));/* ----------------------------------------------------------------\n *  Component\n * ---------------------------------------------------------------- *//**\n * @framerDisableUnlink\n * @framerIntrinsicWidth 1200\n * @framerIntrinsicHeight 600\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function ParallaxMedia({sourceType=\"image\",image,videoUrl=\"\",videoFile=\"\",alt=\"\",direction=\"vertical\",invert=false,radius=0,focalX=50,focalY=50,parallax=25,autoplay=true,loop=true,muted=true,controls=false}){const ref=React.useRef(null);const[size,setSize]=React.useState({width:0,height:0});const[isClient,setIsClient]=React.useState(false);const isStatic=useIsStaticRenderer();const isCanvas=RenderTarget.current()===RenderTarget.canvas;// Reduced motion preference\nconst[prefersReducedMotion,setPrefersReducedMotion]=React.useState(false);React.useEffect(()=>{setIsClient(true);const mq=window.matchMedia(\"(prefers-reduced-motion: reduce)\");setPrefersReducedMotion(mq.matches);const handler=e=>setPrefersReducedMotion(e.matches);mq.addEventListener(\"change\",handler);return()=>mq.removeEventListener(\"change\",handler);},[]);const parallaxActive=isClient&&!isStatic&&!isCanvas&&!prefersReducedMotion;// Measure container\nReact.useLayoutEffect(()=>{if(!isClient||!ref.current||typeof ResizeObserver===\"undefined\")return;const ro=new ResizeObserver(entries=>{const r=entries[0].contentRect;setSize({width:r.width,height:r.height});});ro.observe(ref.current);return()=>ro.disconnect();},[isClient]);// Scroll-driven parallax\nconst{scrollYProgress}=useScroll({target:ref,offset:[\"start end\",\"end start\"]});const base=direction===\"vertical\"?size.height:size.width;const pct=clamp(parallax,5,60)/100;const desiredOverflow=base>0?clamp(base*pct,40,480):0;const scale=base>0?1+desiredOverflow/Math.max(base,1):1.2;const overflow=Math.max(base,1)*(scale-1);const from=invert?overflow/2:-overflow/2;const to=invert?-overflow/2:overflow/2;const mv=useTransform(scrollYProgress,[0,1],[from,to]);const transformOrigin=`${clamp(focalX??50,0,100)}% ${clamp(focalY??50,0,100)}%`;// Resolve media source\nconst resolvedVideo=videoFile&&videoFile.trim()||videoUrl&&videoUrl.trim()||\"\";const hasVideo=resolvedVideo!==\"\";// Handle responsive image (object with src/srcSet) or legacy string\nlet imgSrc=\"\";let imgSrcSet=\"\";if(image&&typeof image===\"object\"&&\"src\"in image){imgSrc=image.src||\"\";imgSrcSet=image.srcSet||\"\";}else if(typeof image===\"string\"){imgSrc=image.trim();}const hasImage=imgSrc!==\"\";const wantVideo=sourceType===\"video\";const renderVideo=wantVideo&&hasVideo||!hasImage&&hasVideo;const renderImage=!renderVideo&&hasImage;// Stable key for remounting on source change\nconst mediaKey=renderVideo?`vid:${resolvedVideo}`:hasImage?`img:${imgSrc}`:\"none\";// Empty state — canvas only\nif(!renderImage&&!renderVideo){if(isCanvas){return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",borderRadius:radius,contain:\"layout\"},children:/*#__PURE__*/_jsxs(\"div\",{style:{position:\"absolute\",inset:0,display:\"flex\",flexDirection:\"column\",justifyContent:\"center\",alignItems:\"center\",background:\"#0f0b1f\",color:\"#b99cff\",padding:\"clamp(12px, 4vw, 24px)\",textAlign:\"center\",gap:\"clamp(12px, 2vw, 16px)\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:\"clamp(14px, 2vw, 18px)\",fontWeight:600},children:\"ParallaxMedia\"}),/*#__PURE__*/_jsx(\"div\",{style:{fontSize:\"clamp(12px, 1.6vw, 14px)\",opacity:.8,maxWidth:\"min(90%, 420px)\",lineHeight:1.45},children:\"Add an Image or Video in the right panel to enable the parallax effect.\"})]})});}return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{position:\"relative\",width:\"100%\",height:\"100%\",borderRadius:radius}});}const mediaStyle={position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:\"cover\",objectPosition:`${focalX}% ${focalY}%`};return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",borderRadius:radius,contain:\"layout\"},children:/*#__PURE__*/_jsx(motion.div,{style:{position:\"absolute\",inset:0,x:parallaxActive&&direction===\"horizontal\"?mv:0,y:parallaxActive&&direction===\"vertical\"?mv:0,scale:parallaxActive?scale:1,transformOrigin,willChange:parallaxActive?\"transform\":\"auto\",backfaceVisibility:\"hidden\"},children:renderVideo?/*#__PURE__*/_jsx(\"video\",{src:resolvedVideo,autoPlay:autoplay,loop:loop,muted:muted,controls:controls,playsInline:true,style:mediaStyle}):/*#__PURE__*/_jsx(\"img\",{src:imgSrc,srcSet:imgSrcSet||undefined,alt:alt,draggable:false,style:{...mediaStyle,pointerEvents:\"none\"}})},mediaKey)});}ParallaxMedia.defaultProps={sourceType:\"image\",videoUrl:\"\",videoFile:\"\",alt:\"\",direction:\"vertical\",invert:false,radius:0,focalX:50,focalY:50,parallax:25,autoplay:true,loop:true,muted:true,controls:false};/* ----------------------------------------------------------------\n *  Property Controls\n * ---------------------------------------------------------------- */addPropertyControls(ParallaxMedia,{sourceType:{type:ControlType.Enum,title:\"Media\",options:[\"image\",\"video\"],optionTitles:[\"Image\",\"Video\"],displaySegmentedControl:true},image:{type:ControlType.ResponsiveImage,title:\"Image\",hidden:p=>p.sourceType===\"video\"},videoUrl:{type:ControlType.String,title:\"Video (URL)\",placeholder:\"https://your.cdn/video.mp4\",hidden:p=>p.sourceType!==\"video\"},videoFile:{type:ControlType.File,title:\"Video (Upload)\",allowedFileTypes:[\"mp4\",\"webm\",\"ogg\",\"mov\"],hidden:p=>p.sourceType!==\"video\",description:\"Upload overrides URL if both are set.\"},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"vertical\",\"horizontal\"],optionTitles:[\"Vertical\",\"Horizontal\"],displaySegmentedControl:true},invert:{type:ControlType.Boolean,title:\"Invert\"},radius:{type:ControlType.Number,title:\"Radius\",min:0,max:64,step:1},focalX:{type:ControlType.Number,title:\"Focal X\",min:0,max:100,step:1},focalY:{type:ControlType.Number,title:\"Focal Y\",min:0,max:100,step:1},parallax:{type:ControlType.Number,title:\"Parallax (%)\",min:5,max:60,step:1,displayStepper:true},autoplay:{type:ControlType.Boolean,title:\"Autoplay\",hidden:p=>p.sourceType!==\"video\"},loop:{type:ControlType.Boolean,title:\"Loop\",hidden:p=>p.sourceType!==\"video\"},muted:{type:ControlType.Boolean,title:\"Muted\",hidden:p=>p.sourceType!==\"video\"},controls:{type:ControlType.Boolean,title:\"Controls\",hidden:p=>p.sourceType!==\"video\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ParallaxMedia\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"600\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"* @framerIntrinsicWidth 1200\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ParallaxMedia.map"],"mappings":"iRAUG,SAAwB,EAAc,CAAC,aAAW,QAAQ,QAAM,WAAS,GAAG,YAAU,GAAG,MAAI,GAAG,YAAU,WAAW,SAAO,GAAM,SAAO,EAAE,SAAO,GAAG,SAAO,GAAG,WAAS,GAAG,WAAS,GAAK,OAAK,GAAK,QAAM,GAAK,WAAS,IAAO,CAAC,IAAM,EAAIA,EAAa,IAAI,EAAO,CAAC,EAAK,GAASC,EAAe,CAAC,MAAM,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