{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/Da01OZwYRzmGJl2CIfjO/RsDuOyNWHrpywF4AQJS0/Loops_Form2.js"],
  "sourcesContent": ["////////////////\n//\n// Using Framer?\n// See https://www.framer.com/learn/code-components/ for more info\n//\n////////////////\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState}from\"react\";const INIT=\"INIT\";const SUBMITTING=\"SUBMITTING\";const ERROR=\"ERROR\";const SUCCESS=\"SUCCESS\";const formStates=[INIT,SUBMITTING,ERROR,SUCCESS];const formStyles={id:\"clgv6cfdj0074l60fogqms9gc\",name:\"Default\",formStyle:\"buttonBelow\",placeholderText:\"you@example.com\",formFont:\"Inter\",formFontColor:\"#000000\",formFontSizePx:14,buttonText:\"Start Now\",buttonFont:\"Inter\",buttonFontColor:\"#ffffff\",buttonColor:\"#FB3657\",buttonFontSizePx:14,successMessage:\"Thanks! We'll be in touch!\",successFont:\"Inter\",successFontColor:\"#000000\",successFontSizePx:14,userGroup:\"API Users\"};const domain=\"app.loops.so\";export default function SignUpFormReact(){const[email,setEmail]=useState(\"\");const[formState,setFormState]=useState(INIT);const[errorMessage,setErrorMessage]=useState(\"\");const resetForm=()=>{setEmail(\"\");setFormState(INIT);setErrorMessage(\"\");};/**\n     * Rate limit the number of submissions allowed\n     * @returns {boolean} true if the form has been successfully submitted in the past minute\n     */ const hasRecentSubmission=()=>{const time=new Date;const timestamp=time.valueOf();const previousTimestamp=localStorage.getItem(\"loops-form-timestamp\");// Indicate if the last sign up was less than a minute ago\nif(previousTimestamp&&Number(previousTimestamp)+60*1e3>timestamp){setFormState(ERROR);setErrorMessage(\"Too many signups, please try again in a little while\");return true;}localStorage.setItem(\"loops-form-timestamp\",timestamp.toString());return false;};const handleSubmit=event=>{// Prevent the default form submission\nevent.preventDefault();// boundary conditions for submission\nif(formState!==INIT)return;if(!isValidEmail(email)){setFormState(ERROR);setErrorMessage(\"Please enter a valid email\");return;}if(hasRecentSubmission())return;setFormState(SUBMITTING);// build body\nconst formBody=`userGroup=${encodeURIComponent(formStyles.userGroup)}&email=${encodeURIComponent(email)}`;// API request to add user to newsletter\nfetch(`https://${domain}/api/newsletter-form/${formStyles.id}`,{method:\"POST\",body:formBody,headers:{\"Content-Type\":\"application/x-www-form-urlencoded\"}}).then(res=>[res.ok,res.json(),res]).then(([ok,dataPromise,res])=>{if(ok){resetForm();setFormState(SUCCESS);window.open(\"https://docs.prodia.com\",\"_blank\");}else{dataPromise.then(data=>{setFormState(ERROR);setErrorMessage(data.message||res.statusText);localStorage.setItem(\"loops-form-timestamp\",\"\");});}}).catch(error=>{setFormState(ERROR);// check for cloudflare error\nif(error.message===\"Failed to fetch\"){setErrorMessage(\"Too many signups, please try again in a little while\");}else if(error.message){setErrorMessage(error.message);}localStorage.setItem(\"loops-form-timestamp\",\"\");});};const isInline=formStyles.formStyle===\"inline\";switch(formState){case SUCCESS:return /*#__PURE__*/ _jsx(\"div\",{style:{display:\"flex\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\"},children:/*#__PURE__*/ _jsx(\"p\",{style:{fontFamily:`'${formStyles.successFont}', sans-serif`,color:formStyles.successFontColor,fontSize:`${formStyles.successFontSizePx}px`},children:formStyles.successMessage})});case ERROR:return /*#__PURE__*/ _jsxs(_Fragment,{children:[/*#__PURE__*/ _jsx(SignUpFormError,{}),/*#__PURE__*/ _jsx(BackButton,{})]});default:return /*#__PURE__*/ _jsx(_Fragment,{children:/*#__PURE__*/ _jsxs(\"form\",{onSubmit:handleSubmit,style:{display:\"flex\",flexDirection:isInline?\"row\":\"column\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\"},children:[/*#__PURE__*/ _jsx(\"input\",{type:\"text\",name:\"email\",placeholder:formStyles.placeholderText,value:email,onChange:e=>setEmail(e.target.value),required:true,style:{color:formStyles.formFontColor,fontFamily:`'${formStyles.formFont}', sans-serif`,fontSize:`${formStyles.formFontSizePx}px`,margin:isInline?\"0px 10px 0px 0px\":\"0px 0px 10px\",width:\"100%\",maxWidth:\"300px\",minWidth:\"100px\",background:\"#FFFFFF\",border:\"1px solid #D1D5DB\",boxSizing:\"border-box\",boxShadow:\"rgba(0, 0, 0, 0.05) 0px 1px 2px\",borderRadius:\"6px\",padding:\"8px 12px\"}}),/*#__PURE__*/ _jsx(SignUpFormButton,{})]})});}function SignUpFormError(){return /*#__PURE__*/ _jsx(\"div\",{style:{alignItems:\"center\",justifyContent:\"center\",width:\"100%\"},children:/*#__PURE__*/ _jsx(\"p\",{style:{fontFamily:\"Inter, sans-serif\",color:\"rgb(185, 28, 28)\",fontSize:\"14px\"},children:errorMessage||\"Oops! Something went wrong, please try again\"})});}function BackButton(){const[isHovered,setIsHovered]=useState(false);return /*#__PURE__*/ _jsx(\"button\",{style:{color:\"#6b7280\",font:\"14px, Inter, sans-serif\",margin:\"10px auto\",textAlign:\"center\",background:\"transparent\",border:\"none\",cursor:\"pointer\",textDecoration:isHovered?\"underline\":\"none\"},onMouseOut:()=>setIsHovered(false),onMouseOver:()=>setIsHovered(true),onClick:resetForm,children:\"\u2190 Back\"});}function SignUpFormButton({props}){return /*#__PURE__*/ _jsx(\"button\",{type:\"submit\",style:{background:formStyles.buttonColor,fontSize:`${formStyles.buttonFontSizePx}px`,color:formStyles.buttonFontColor,fontFamily:`'${formStyles.buttonFont}', sans-serif`,width:isInline?\"min-content\":\"100%\",maxWidth:\"300px\",whiteSpace:isInline?\"nowrap\":\"normal\",height:\"38px\",alignItems:\"center\",justifyContent:\"center\",flexDirection:\"row\",padding:\"9px 17px\",boxShadow:\"0px 1px 2px rgba(0, 0, 0, 0.05)\",borderRadius:\"6px\",textAlign:\"center\",fontStyle:\"normal\",fontWeight:500,lineHeight:\"20px\",border:\"none\",cursor:\"pointer\"},children:formState===SUBMITTING?\"Please wait...\":formStyles.buttonText});}};function isValidEmail(email){return/.+@.+/.test(email);}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"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W,qBAAqB,MAAMA,EAAW,gBAAgB,WAAW,IAAIA,EAAW,0BAA0B,MAAM4B,EAAS,cAAc,OAAO,SAAS,QAAQ,WAAWA,EAAS,SAAS,SAAS,OAAO,OAAO,WAAW,SAAS,eAAe,SAAS,cAAc,MAAM,QAAQ,WAAW,UAAU,kCAAkC,aAAa,MAAM,UAAU,SAAS,UAAU,SAAS,WAAW,IAAI,WAAW,OAAO,OAAO,OAAO,OAAO,SAAS,EAAE,SAAStB,IAAYa,EAAW,iBAAiBnB,EAAW,UAAU,CAAC,CAAE,CAAC,CAAE,SAASkB,EAAaf,EAAM,CAAC,MAAM,QAAQ,KAAKA,CAAK,CAAE",
  "names": ["INIT", "SUBMITTING", "ERROR", "SUCCESS", "formStyles", "domain", "SignUpFormReact", "email", "setEmail", "ye", "formState", "setFormState", "INIT", "errorMessage", "setErrorMessage", "resetForm", "hasRecentSubmission", "timestamp", "previousTimestamp", "ERROR", "handleSubmit", "event", "isValidEmail", "SUBMITTING", "formBody", "res", "ok", "dataPromise", "SUCCESS", "window", "data", "error", "isInline", "p", "u", "l", "SignUpFormError", "BackButton", "e", "SignUpFormButton", "isHovered", "setIsHovered", "props"]
}
