{"version":3,"file":"Image_carousel.C5D3_Nw3.mjs","names":["useState","__esmMin","j","init_npm_react_18_3_1","ce","init_jsx_runtime","Ba","p","_e","motion","init_framer_motion_DhsWWWsN","addPropertyControls","init_framer_DJ_0WPVq","ControlType","RichTextCarousel","props","imageSrcs","setImageSrcs","currentIndex","setCurrentIndex","lightboxSrc","setLightboxSrc","extractImages","images","searchForImages","element","child","richText","handleNext","showFirstImageOnly","prevIndex","handlePrev","getImageStyle","heightMode","getTransition","transitionType","displayedImages","Frame","imageSpacing","enableLightbox","src","index","arrowSize","arrowImage","Lightbox","init_Image_carousel","init_npm_react_dom_18_3_1","onClose"],"sources":["https:/framerusercontent.com/modules/6SFQOOr7pyMlZBzgKSs8/m2QVSRgfdp6eWmcFy5IG/Image_carousel.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{Frame,addPropertyControls,ControlType}from\"framer\";import{useEffect,useState}from\"react\";import{motion}from\"framer-motion\";import ReactDOM from\"react-dom\";const Lightbox=({src,onClose})=>{useEffect(()=>{document.body.style.overflow=\"hidden\";return()=>{document.body.style.overflow=\"unset\";};},[]);return /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/_jsx(\"div\",{style:{position:\"fixed\",top:0,left:0,width:\"100%\",height:\"100%\",backgroundColor:\"rgba(0, 0, 0, 0.8)\",zIndex:9999999,display:\"flex\",justifyContent:\"center\",alignItems:\"center\"},onClick:onClose,children:/*#__PURE__*/_jsx(\"img\",{src:src,style:{maxWidth:\"90%\",maxHeight:\"90%\",objectFit:\"contain\"},onClick:e=>e.stopPropagation()})}),document.body);};/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 600\n */export default function RichTextCarousel(props){const{richText,arrowImage=\"https://cdn-icons-png.freepik.com/512/1/1122.png\",imageSpacing,heightMode,transitionType,showFirstImageOnly,arrowSize,enableLightbox}=props;const[imageSrcs,setImageSrcs]=useState([]);const[currentIndex,setCurrentIndex]=useState(0);const[lightboxSrc,setLightboxSrc]=useState(null);useEffect(()=>{const extractImages=element=>{const images=[];const searchForImages=element=>{if(element.props&&element.props.children){React.Children.forEach(element.props.children,child=>{if(typeof child===\"object\"&&child.type===\"img\"){images.push(child.props.src);}else if(child.props&&child.props.children){searchForImages(child);}});}};searchForImages(element);return images;};if(richText&&richText.props&&Array.isArray(richText.props.children)){const images=extractImages(richText);setImageSrcs(images);}},[richText]);useEffect(()=>{if(imageSrcs.length&&currentIndex<0){setCurrentIndex(imageSrcs.length-1);}else if(imageSrcs.length&&currentIndex>=imageSrcs.length){setCurrentIndex(0);}},[currentIndex,imageSrcs.length]);const handleNext=()=>{if(!showFirstImageOnly){setCurrentIndex(prevIndex=>(prevIndex+1)%imageSrcs.length);}};const handlePrev=()=>{if(!showFirstImageOnly){setCurrentIndex(prevIndex=>(prevIndex-1+imageSrcs.length)%imageSrcs.length);}};const getImageStyle=()=>{switch(heightMode){case\"fit\":return{width:\"100%\",height:\"auto\",objectFit:\"contain\",backgroundColor:\"transparent\"};case\"fill\":return{width:\"100%\",height:\"100%\",objectFit:\"cover\",backgroundColor:\"transparent\"};case\"stretch\":return{width:\"100%\",height:\"100%\",objectFit:\"fill\",backgroundColor:\"transparent\"};default:return{width:\"100%\",height:\"auto\",objectFit:\"contain\",backgroundColor:\"transparent\"};}};const getTransition=()=>{switch(transitionType){case\"easeIn\":return{type:\"spring\",stiffness:100,damping:10};case\"easeOut\":return{type:\"tween\",ease:\"easeOut\",duration:.5};case\"linear\":return{type:\"tween\",ease:\"linear\",duration:.5};default:return{type:\"spring\",stiffness:100,damping:10};}};const displayedImages=showFirstImageOnly?[imageSrcs[0]]:imageSrcs;return /*#__PURE__*/_jsxs(Frame,{overflow:\"hidden\",position:\"relative\",style:{width:\"100%\",height:\"100%\",backgroundColor:\"transparent\"},children:[/*#__PURE__*/_jsx(motion.div,{style:{display:\"flex\",width:`${100*displayedImages.length}%`,height:\"100%\",flexDirection:\"row\",backgroundColor:\"transparent\",marginLeft:`-${imageSpacing/2}px`,marginRight:`-${imageSpacing/2}px`},animate:{x:`-${currentIndex*(100/displayedImages.length)}%`},transition:getTransition(),children:displayedImages.map((src,index)=>/*#__PURE__*/_jsx(\"div\",{style:{width:`calc(${100/displayedImages.length}% - ${imageSpacing}px)`,height:\"100%\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",backgroundColor:\"transparent\",paddingLeft:`${imageSpacing/2}px`,paddingRight:`${imageSpacing/2}px`},children:/*#__PURE__*/_jsx(\"img\",{src:src,style:{...getImageStyle(),cursor:enableLightbox?\"pointer\":\"default\"},onClick:()=>{if(enableLightbox){setLightboxSrc(src);}}})},index))}),!showFirstImageOnly&&currentIndex!==0&&/*#__PURE__*/_jsx(Frame,{width:arrowSize,height:arrowSize,top:\"50%\",left:\"16px\",background:\"transparent\",style:{backgroundImage:`url(${arrowImage})`,transform:\"rotate(180deg)\",backgroundSize:\"contain\",backgroundRepeat:\"no-repeat\",backgroundPosition:\"center\",cursor:\"pointer\",backgroundColor:\"transparent\"},onTap:handlePrev}),!showFirstImageOnly&&currentIndex!==displayedImages.length-1&&/*#__PURE__*/_jsx(Frame,{width:arrowSize,height:arrowSize,top:\"50%\",right:\"16px\",background:\"transparent\",style:{backgroundImage:`url(${arrowImage})`,backgroundSize:\"contain\",backgroundRepeat:\"no-repeat\",backgroundPosition:\"center\",cursor:\"pointer\",backgroundColor:\"transparent\"},onTap:handleNext}),enableLightbox&&lightboxSrc&&/*#__PURE__*/_jsx(Lightbox,{src:lightboxSrc,onClose:()=>setLightboxSrc(null)})]});}RichTextCarousel.defaultProps={richText:{},arrowImage:\"https://cdn-icons-png.freepik.com/512/1/1122.png\",imageSpacing:0,heightMode:\"fit\",transitionType:\"easeIn\",showFirstImageOnly:false,arrowSize:50,enableLightbox:true};addPropertyControls(RichTextCarousel,{richText:{title:\"Rich Text\",type:ControlType.RichText},arrowImage:{title:\"Arrow Image\",type:ControlType.Image,defaultValue:\"https://cdn-icons-png.freepik.com/512/1/1122.png\"},heightMode:{title:\"Height Mode\",type:ControlType.Enum,options:[\"fit\",\"fill\",\"stretch\"],optionTitles:[\"Fit\",\"Fill\",\"Stretch\"],defaultValue:\"fit\"},transitionType:{title:\"Transition\",type:ControlType.Enum,options:[\"easeIn\",\"easeOut\",\"linear\"],optionTitles:[\"Ease In\",\"Ease Out\",\"Linear\"],defaultValue:\"easeIn\"},showFirstImageOnly:{title:\"Show First Image Only\",type:ControlType.Boolean,defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},enableLightbox:{title:\"Lightbox\",type:ControlType.Boolean,defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},arrowSize:{title:\"Arrow Size\",type:ControlType.Number,defaultValue:50,min:10,max:100,unit:\"px\",description:\"v1.3 \\n [via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RichTextCarousel\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"600\",\"framerIntrinsicHeight\":\"600\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Image_carousel.map"],"mappings":"A,sPAOG,SAAwBc,EAAiB,EAAM,CAAC,GAAK,CAAC,WAAS,aAAW,mDAAmD,eAAa,aAAW,iBAAe,qBAAmB,YAAU,kBAAgBC,EAAW,CAACC,EAAUC,GAAcjB,EAAS,CAAC,CAAC,EAAO,CAACkB,EAAaC,GAAiBnB,EAAS,CAAC,EAAO,CAACoB,EAAYC,GAAgBrB,EAAS,IAAI,EAAEI,MAAc,CAAC,IAAMkB,EAAc,GAAS,CAAC,IAAMC,EAAO,CAAC,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