{"version":3,"file":"SignUpButtonOverride.CLuzgyRE.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/qCJiHih07GSwSsOmWuAj/aXPKoJr3EtnvVejmRQ7w/SignUpButtonOverride.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState}from\"react\";export function withCustomButtonClick(Component){return props=>{const buttonRef=useRef(null);const[isLoading,setIsLoading]=useState(false);const onClick=async e=>{e&&e.preventDefault();if(isLoading)return;// Prevent multiple submissions\nsetIsLoading(true);try{// Get form data from the page\nconst urlParams=new URLSearchParams(window.location.search);const formData={plan:\"yearly\",coupon:urlParams.get(\"coupon\"),email:urlParams.get(\"email\"),code:urlParams.get(\"code\")};// Call the API endpoint\nconst response=await fetch(\"https://members.provenvalor.com/api/v1/framer/sign-up\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(formData)});const result=await response.json();if(result.error){console.error(\"API Error:\",result.message);// Handle error - show user feedback\nshowError(result.message);}else{console.log(\"Success:\",result.message);// Handle success - redirect or show success message\nhandleSuccess(result);}}catch(error){console.error(\"Network Error:\",error);showError(\"Network error. Please try again.\");}finally{setIsLoading(false);}};useEffect(()=>{const button=buttonRef.current;if(button){button.addEventListener(\"click\",onClick);}return()=>{button&&button.removeEventListener(\"click\",onClick);};},[]);// Create disabled styles object\nconst disabledStyles=isLoading?{opacity:.8,cursor:\"not-allowed\",pointerEvents:\"none\",position:\"relative\"}:{};// Merge with existing styles\nconst mergedStyles={//@ts-expect-error\n...props.style,...disabledStyles};// Add CSS for the spinner animation\nuseEffect(()=>{const style=document.createElement(\"style\");style.textContent=`\n        @keyframes button-spin {\n          0% { transform: translate(-50%, -50%) rotate(0deg); }\n          100% { transform: translate(-50%, -50%) rotate(360deg); }\n        }\n        .button-loading-spinner {\n          position: absolute;\n          top: 50%;\n          left: 50%;\n          transform: translate(-50%, -50%);\n          width: 20px;\n          height: 20px;\n          border: 2px solid transparent;\n          border-top: 2px solid currentColor;\n          border-radius: 50%;\n          animation: button-spin 1s linear infinite;\n        }\n      `;document.head.appendChild(style);return()=>{document.head.removeChild(style);};},[]);// Add spinner element after component mounts\nuseEffect(()=>{const button=buttonRef.current;if(button&&isLoading){// Remove any existing spinner\nconst existingSpinner=button.querySelector(\".button-loading-spinner\");if(existingSpinner){existingSpinner.remove();}// Add new spinner\nconst spinner=document.createElement(\"div\");spinner.className=\"button-loading-spinner\";button.appendChild(spinner);return()=>{const spinnerToRemove=button.querySelector(\".button-loading-spinner\");if(spinnerToRemove){spinnerToRemove.remove();}};}},[isLoading]);return /*#__PURE__*/_jsx(Component,{...props,//@ts-expect-error\nref:buttonRef,disabled:isLoading,style:mergedStyles,onClick:onClick});};}// Helper function to show error messages\nfunction showError(message){alert(`Error: ${message}`);}// Helper function to handle success\nfunction handleSuccess(result){// Redirect if a redirect URL is provided\nif(result.data?.redirectUrl){window.location.href=result.data.redirectUrl;}else{// Show success message\nalert(\"Sign up successful!\");}}\nexport const __FramerMetadata__ = {\"exports\":{\"withCustomButtonClick\":{\"type\":\"reactHoc\",\"name\":\"withCustomButtonClick\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SignUpButtonOverride.map"],"mappings":"mNAAwF,SAAgB,EAAsB,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAUA,EAAO,KAAK,CAAM,CAAC,EAAU,GAAcC,EAAS,GAAM,CAAO,EAAQ,KAAM,IAAG,CAAC,MAAG,EAAE,gBAAgB,CAAI,GACpR,GAAa,GAAK,CAAC,GAAG,CACtB,IAAM,EAAU,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAO,EAAS,CAAC,KAAK,SAAS,OAAO,EAAU,IAAI,SAAS,CAAC,MAAM,EAAU,IAAI,QAAQ,CAAC,KAAK,EAAU,IAAI,OAAO,CAAC,CACG,EAAO,MAA5K,MAAM,MAAM,wDAAwD,CAAC,OAAO,OAAO,Q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