{"version":3,"file":"UniversalCodeButton.BK79agoq.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/AMaMejQ2GP0UNLpIMFn3/h5uZVJuJfDF51ndo9fso/UniversalCodeButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function DynamicButton(props){const{defaultText,defaultUrl,loggedInText,loggedInUrl,bgColor,hoverBgColor,image,imageSize,imageAlt,buttonWidth,buttonHeight,isFullWidth,borderRadius,textSize,textColor,fontFamily,fontWeight,showWhenLoggedIn}=props;const[text,setText]=useState(defaultText);const[url,setUrl]=useState(defaultUrl);const[isHover,setIsHover]=useState(false);const[store,setStore]=useState({userData:null,loading:true});// Smooth animation on appear\nconst[isLoaded,setIsLoaded]=useState(false);useEffect(()=>{const timer=setTimeout(()=>setIsLoaded(true),50);return()=>clearTimeout(timer);},[]);// Check user login status\nuseEffect(()=>{let mounted=true;async function checkLogin(){try{const res=await fetch(\"/api/me\",{credentials:\"include\"});if(!mounted)return;if(!res.ok){setStore({userData:null,loading:false});return;}const data=await res.json();setStore({userData:data,loading:false});}catch(err){setStore({userData:null,loading:false});console.error(\"DynamicButton: /api/me error:\",err);}}checkLogin();return()=>mounted=false;},[]);const isLoggedIn=!!store.userData?.message;// Update text & URL based on login\nuseEffect(()=>{if(!store.loading){setText(isLoggedIn?loggedInText:defaultText);setUrl(isLoggedIn?loggedInUrl:defaultUrl);}},[store.loading,isLoggedIn,loggedInText,loggedInUrl,defaultText,defaultUrl]);// ICON render helper\nconst renderImage=()=>{if(!image)return null;const src=typeof image===\"string\"?image:image?.url||\"\";if(!src)return null;return /*#__PURE__*/_jsx(\"img\",{src:src,alt:imageAlt||\"button-image\",style:{width:imageSize,height:imageSize,objectFit:\"cover\",display:\"block\",borderRadius:999}});};return /*#__PURE__*/_jsxs(\"a\",{href:url,onMouseEnter:()=>setIsHover(true),onMouseLeave:()=>setIsHover(false),style:{width:isFullWidth?\"100%\":buttonWidth?`${buttonWidth}px`:\"auto\",height:buttonHeight?`${buttonHeight}px`:\"auto\",padding:\"0 20px\",borderRadius,background:isHover?hoverBgColor:bgColor,color:textColor,textDecoration:\"none\",// 🔥 Display rule change\ndisplay:isLoggedIn&&!showWhenLoggedIn?\"none\":\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",gap:\"10px\",cursor:\"pointer\",fontFamily,fontWeight,transition:\"opacity 0.4s ease, transform 0.4s ease\",opacity:isLoaded?1:0,transform:isLoaded?\"translateY(0)\":\"translateY(10px)\"},children:[renderImage(),/*#__PURE__*/_jsx(\"span\",{style:{fontSize:textSize,lineHeight:1},children:text})]});}// Framer Controls\naddPropertyControls(DynamicButton,{defaultText:{type:ControlType.String,title:\"Default Text\",defaultValue:\"Try for Free\"},defaultUrl:{type:ControlType.String,title:\"Default URL\",defaultValue:\"/signup\"},loggedInText:{type:ControlType.String,title:\"Logged-In Text\",defaultValue:\"Go to Dashboard\"},loggedInUrl:{type:ControlType.String,title:\"Logged-In URL\",defaultValue:\"/dashboard\"},showWhenLoggedIn:{type:ControlType.Boolean,title:\"Show only if Logged-In\",defaultValue:true},bgColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#007ee5\"},hoverBgColor:{type:ControlType.Color,title:\"Hover Background\",defaultValue:\"#005bb5\"},isFullWidth:{type:ControlType.Boolean,title:\"Full Width\",defaultValue:false},buttonWidth:{type:ControlType.Number,title:\"Width\",defaultValue:180,min:80,max:500,step:1,hidden:props=>props.isFullWidth},buttonHeight:{type:ControlType.Number,title:\"Height\",defaultValue:48,min:30,max:100,step:1},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:100},textSize:{type:ControlType.Number,title:\"Text Size\",defaultValue:16,min:10,max:40,step:1},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},fontFamily:{type:ControlType.Enum,title:\"Font\",options:[\"Inter\",\"Arial\",\"Roboto\",\"Poppins\",\"Montserrat\",\"Open Sans\",\"Nunito\"],optionTitles:[\"Inter\",\"Arial\",\"Roboto\",\"Poppins\",\"Montserrat\",\"Open Sans\",\"Nunito\"],defaultValue:\"Inter\"},fontWeight:{type:ControlType.Enum,title:\"Font Weight\",options:[\"400\",\"500\",\"600\",\"700\",\"800\",\"900\"],optionTitles:[\"Regular\",\"Medium\",\"Semi Bold\",\"Bold\",\"Extra Bold\",\"Black\"],defaultValue:\"600\"},image:{type:ControlType.Image,title:\"Image\",defaultValue:null},imageSize:{type:ControlType.Number,title:\"Image Size\",defaultValue:24,min:8,max:128,step:1},imageAlt:{type:ControlType.String,title:\"Image Alt\",defaultValue:\"icon\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DynamicButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./UniversalCodeButton.map"],"mappings":"wLAAmJ,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,cAAY,aAAW,eAAa,cAAY,UAAQ,eAAa,QAAM,YAAU,WAAS,cAAY,eAAa,cAAY,eAAa,WAAS,YAAU,aAAW,aAAW,oBAAkB,EAAW,CAAC,EAAK,GAASA,EAAS,EAAY,CAAM,CAAC,EAAI,GAAQA,EAAS,EAAW,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAM,CAAC,EAAM,GAAUA,EAAS,CAAC,SAAS,KAAK,QAAQ,GAAK,CAAC,CACzkB,CAAC,EAAS,GAAaA,EAAS,GAAM,CAAC,MAAc,CAAC,IAAM,EAAM,eAAe,EAAY,GAAK,CAAC,GAAG,CAAC,UAAU,aAAa,EAAM,EAAG,EAAE,CAAC,CAC/I,MAAc,CAAC,IAAI,EAAQ,GAAK,eAAe,GAAY,CAAC,GAAG,CAAC,IAAM,EAAI,MAAM,MAAM,UAAU,CAAC,YAAY,UAAU,CAAC,CAAC,GAAG,CAAC,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