{"version":3,"file":"SwipeCards.kRtwZDOS.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/VoIOqre95tI1ywMfh5eV/8XZ35J9NHjh8G8bxXKRZ/SwipeCards.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import React,{useState,useEffect}from\"react\";import{motion,useMotionValue,useTransform}from\"framer-motion\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function SwipeableInstances(props){const[currentIndex,setCurrentIndex]=useState(0);const x=useMotionValue(0);const rotate=useTransform(x,[-200,200],[-30,30]);const opacity=useTransform(x,[-200,-100,0,100,200],[0,1,1,1,0]);const isCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{console.log(\"Number of instances:\",props.instances.length);},[props.instances]);const handleDragEnd=(event,info)=>{const threshold=50// Minimum drag distance to trigger a change\n;if(Math.abs(info.offset.x)>threshold){if(info.offset.x<0){// Dragged left, go to previous card\nsetCurrentIndex(prevIndex=>(prevIndex-1+props.instances.length)%props.instances.length);}else{// Dragged right, go to next card\nsetCurrentIndex(prevIndex=>(prevIndex+1)%props.instances.length);}}x.set(0)// Reset the x position\n;};const currentInstance=props.instances[currentIndex];if(isCanvas&&(!currentInstance||props.instances.length===0)){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",border:\"1px dashed #594FEE\",borderRadius:\"8px\",backgroundColor:\"#EEEDFD\",color:\"#594FEE\",fontFamily:\"Arial, sans-serif\",padding:\"20px\",textAlign:\"center\"},children:\"Please connect to an instance\"});}if(!currentInstance)return null;return /*#__PURE__*/_jsx(motion.div,{style:{width:currentInstance.width,height:currentInstance.height,x,rotate,opacity,cursor:\"grab\"},drag:\"x\",dragConstraints:{left:0,right:0},onDragEnd:handleDragEnd,whileDrag:{cursor:\"grabbing\"},children:/*#__PURE__*/React.cloneElement(currentInstance)});}addPropertyControls(SwipeableInstances,{instances:{type:ControlType.Array,control:{type:ControlType.ComponentInstance},title:\"Instances\",description:\"v1.0 \\n[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SwipeableInstances\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SwipeCards.map"],"mappings":"yZAKG,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,EAAa,GAAiBA,EAAS,EAAE,CAAO,EAAE,EAAe,EAAE,CAAO,EAAO,EAAa,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAO,EAAQ,EAAa,EAAE,CAAC,KAAK,KAAK,EAAE,IAAI,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAO,EAAS,EAAa,SAAS,GAAG,EAAa,OAAO,MAAc,CAAC,QAAQ,IAAI,uBAAuB,EAAM,UAAU,OAAO,EAAG,CAAC,EAAM,UAAU,CAAC,CAAC,IAAM,GAAe,EAAM,IAAO,CACza,KAAK,IAAI,EAAK,OAAO,EAAE,CADma,KACpZ,EAAK,OAAO,EAAE,EACxD,EAAgB,IAAY,EAAU,EAAE,EAAM,UAAU,QAAQ,EAAM,UAAU,OAAO,CACvF,EAAgB,IAAY,EAAU,GAAG,EAAM,UAAU,OAAO,EAAG,EAAE,IAAI,EAAE,EAClE,EAAgB,EAAM,UAAU,GAA+a,OAA9Z,IAAW,CAAC,GAAiB,EAAM,UAAU,SAAS,GAAwB,EAAK,MAAM,CAAC,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,QAAQ,OAAO,eAAe,SAAS,WAAW,SAAS,OAAO,qBAAqB,aAAa,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