{"version":3,"file":"SignUp.C9Qq1V-R.mjs","names":["useState","error"],"sources":["https:/framerusercontent.com/modules/T6dNUEGlw9NaW8H3YnkQ/xU8PmhhuRkjogcbwlZH8/SignUp.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{supabase}from\"https://framerusercontent.com/modules/aYAdvYnepRDw6bKJ4Fjl/nQp6uR7lLhMp9LCodIsG/SupabaseClient.js\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{MdVisibility,MdVisibilityOff,MdRefresh}from\"react-icons/md\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function SignUpForm({placeholderUsername,placeholderEmail,placeholderPassword,buttonText,font,fontSize,fontWeight,buttonColor,buttonTextColor,inputBorderColor,inputBackgroundColor,inputTextColor,inputPadding,borderRadius,labelUsername,labelEmail,labelPassword,labelFontWeight,inputFontWeight,labelSpacing,redirectUrl,actionType}){const[username,setUsername]=useState(\"\");const[email,setEmail]=useState(\"\");const[password,setPassword]=useState(\"\");const[showPassword,setShowPassword]=useState(false);const[error,setError]=useState(null);const[success,setSuccess]=useState(null);const[loading,setLoading]=useState(false);useEffect(()=>{const styles=`\n            .spin {\n                animation: spin 1s linear infinite;\n            }\n            @keyframes spin {\n                0% { transform: rotate(0deg); }\n                100% { transform: rotate(360deg); }\n            }\n        `;const styleElement=document.createElement(\"style\");styleElement.innerHTML=styles;document.head.appendChild(styleElement);return()=>{document.head.removeChild(styleElement);};},[]);const handleSignUp=async e=>{e.preventDefault();setError(null);setSuccess(null);setLoading(true);// Validate the username before proceeding\nif(!username){setError(\"Por favor, forne\\xe7a um nome de usu\\xe1rio.\");setLoading(false);return;}if(!/^[a-z0-9_]{3,20}$/.test(username)){setError(\"O nome de usu\\xe1rio deve ter entre 3 e 20 caracteres e s\\xf3 pode conter letras min\\xfasculas, n\\xfameros e underscores.\");setLoading(false);return;}// Check if the username already exists\nconst{data:existingUser,error:usernameCheckError}=await supabase.from(\"user_profiles\").select(\"username\").eq(\"username\",username).single();if(existingUser){setError(\"Este nome de usu\\xe1rio j\\xe1 est\\xe1 em uso. Por favor, escolha outro.\");setLoading(false);return;}try{// Sign up the user\nconst{data,error}=await supabase.auth.signUp({email,password,options:{data:{username:username,display_name:username}}});if(error){translateErrorMessage(error.message);setLoading(false);return;}// Get the user data after successful sign-up\nconst{data:userData,error:getUserError}=await supabase.auth.getUser();if(getUserError||!userData.user){setError(\"Erro ao obter informa\\xe7\\xf5es do usu\\xe1rio ap\\xf3s o cadastro.\");setLoading(false);return;}const userId=userData.user.id;// Insert a new profile or update if it already exists\nconst{error:upsertError}=await supabase.from(\"user_profiles\").upsert([{user_id:userId,username:username}],{onConflict:\"user_id\"});if(upsertError){setError(\"Erro ao salvar o perfil do usu\\xe1rio.\");setLoading(false);return;}setSuccess(\"Cadastro realizado com sucesso!\");setTimeout(()=>{if(actionType===\"verify\"||actionType===\"rate\"||actionType===\"favorite\"){// Redirect with a query parameter for verify or rate flow\nconst currentUrl=new URL(window.location.href);currentUrl.searchParams.set(\"signupAction\",actionType);window.location.href=currentUrl.toString();}else{// Redirect to the home page for the \"None\" case\nwindow.location.href=\"https://www.missalis.com.br/\";}},1e3);}catch(err){console.error(\"Unexpected error:\",err);setError(\"Erro inesperado durante o cadastro.\");}finally{setLoading(false);}};const translateErrorMessage=message=>{switch(message){case\"Password should be at least 6 characters.\":setError(\"A senha deve ter pelo menos 6 caracteres\");break;case\"User already registered\":setError(\"Este nome de usu\\xe1rio ou e-mail j\\xe1 est\\xe1 em uso. Por favor, escolha outro.\");break;case\"To signup, please provide your email\":setError(\"Para se cadastrar, por favor forne\\xe7a seu e-mail\");break;case\"Signup requires a valid password\":setError(\"O cadastro requer uma senha v\\xe1lida\");break;case\"User already registered\":setError(\"Usu\\xe1rio j\\xe1 registrado\");break;case\"Only an email address or phone number should be provided on signup.\":setError(\"Apenas um endere\\xe7o de e-mail deve ser fornecido no cadastro.\");break;case\"Signups not allowed for this instance\":setError(\"Cadastros n\\xe3o permitidos para esta inst\\xe2ncia\");break;case\"Email signups are disabled\":setError(\"Cadastros por e-mail est\\xe3o desativados\");break;case\"Email link is invalid or has expired\":setError(\"O link do e-mail \\xe9 inv\\xe1lido ou expirou\");break;case\"Token has expired or is invalid\":setError(\"O token expirou ou \\xe9 inv\\xe1lido\");break;case\"The new email address provided is invalid\":setError(\"O novo endere\\xe7o de e-mail fornecido \\xe9 inv\\xe1lido\");break;case\"Password should be at least 6 characters\":setError(\"A senha deve ter pelo menos 6 caracteres\");break;case\"Invalid login credentials\":setError(\"Credenciais de login inv\\xe1lidas\");break;case\"Anonymous sign-ins are disabled\":setError(\"Por favor, insira um e-mail v\\xe1lido\");break;default:setError(\"Ocorreu um erro desconhecido. Por favor, tente novamente.\");}};const inputStyle={fontFamily:font,fontSize,fontWeight:inputFontWeight,borderColor:inputBorderColor,backgroundColor:inputBackgroundColor,color:inputTextColor,padding:inputPadding,borderRadius:borderRadius,borderWidth:1,borderStyle:\"solid\",width:\"100%\",boxSizing:\"border-box\"};const buttonStyle={backgroundColor:buttonColor,color:buttonTextColor,fontFamily:font,fontSize,fontWeight:600,padding:`${inputPadding}px ${inputPadding*2}px`,borderRadius:borderRadius,border:\"none\",width:\"100%\",cursor:\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"};const labelStyle={fontFamily:font,fontSize,fontWeight:labelFontWeight,lineHeight:labelSpacing};return /*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSignUp,style:{width:\"100%\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{marginBottom:12},children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:\"Nome de usu\\xe1rio\"}),/*#__PURE__*/_jsx(\"input\",{type:\"text\",placeholder:placeholderUsername,value:username,onChange:e=>setUsername(e.target.value.toLowerCase().replace(/\\s/g,\"\")),style:inputStyle})]}),/*#__PURE__*/_jsxs(\"div\",{style:{marginBottom:12},children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:labelEmail}),/*#__PURE__*/_jsx(\"input\",{type:\"email\",placeholder:placeholderEmail,value:email,onChange:e=>setEmail(e.target.value),style:inputStyle})]}),/*#__PURE__*/_jsxs(\"div\",{style:{marginBottom:24,position:\"relative\"},children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:labelPassword}),/*#__PURE__*/_jsx(\"input\",{type:showPassword?\"text\":\"password\",placeholder:placeholderPassword,value:password,onChange:e=>setPassword(e.target.value),style:{...inputStyle,paddingRight:40}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",right:10,top:\"72%\",transform:\"translateY(-50%)\",cursor:\"pointer\"},onClick:()=>setShowPassword(!showPassword),children:showPassword?/*#__PURE__*/_jsx(MdVisibilityOff,{size:24}):/*#__PURE__*/_jsx(MdVisibility,{size:24})})]}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",style:buttonStyle,disabled:loading,children:loading?/*#__PURE__*/_jsx(MdRefresh,{size:24,className:\"spin\"}):buttonText}),error&&/*#__PURE__*/_jsx(\"div\",{style:{color:\"red\",marginTop:12},children:error}),success&&/*#__PURE__*/_jsx(\"div\",{style:{color:\"green\",marginTop:12},children:success})]});}// Default props for the component\nSignUpForm.defaultProps={placeholderUsername:\"Nome de usu\\xe1rio\",placeholderEmail:\"E-mail\",placeholderPassword:\"Senha\",buttonText:\"Criar conta\",font:\"Work Sans\",fontSize:16,fontWeight:500,buttonColor:\"#E91E63\",buttonTextColor:\"#FFFFFF\",inputBorderColor:\"#CCCCCC\",inputBackgroundColor:\"#F9F9F9\",inputTextColor:\"#333333\",inputPadding:12,borderRadius:8,labelUsername:\"Nome de usu\\xe1rio\",labelEmail:\"E-mail\",labelPassword:\"Senha\",labelFontWeight:500,inputFontWeight:400,labelSpacing:2,redirectUrl:\"https://www.missalis.com.br\",actionType:\"verify\"};// Add property controls to make the component customizable\naddPropertyControls(SignUpForm,{placeholderUsername:{type:ControlType.String,title:\"Username Placeholder\"},placeholderEmail:{type:ControlType.String,title:\"Email Placeholder\"},placeholderPassword:{type:ControlType.String,title:\"Password Placeholder\"},buttonText:{type:ControlType.String,title:\"Button Text\"},font:{type:ControlType.String,title:\"Font\"},fontSize:{type:ControlType.Number,title:\"Font Size\"},fontWeight:{type:ControlType.Number,title:\"Font Weight\"},buttonColor:{type:ControlType.Color,title:\"Button Color\"},buttonTextColor:{type:ControlType.Color,title:\"Button Text Color\"},inputBorderColor:{type:ControlType.Color,title:\"Input Border Color\"},inputBackgroundColor:{type:ControlType.Color,title:\"Input Background Color\"},inputTextColor:{type:ControlType.Color,title:\"Input Text Color\"},inputPadding:{type:ControlType.Number,title:\"Input Padding\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\"},labelUsername:{type:ControlType.String,title:\"Username Label\"},labelEmail:{type:ControlType.String,title:\"Email Label\"},labelPassword:{type:ControlType.String,title:\"Password Label\"},labelFontWeight:{type:ControlType.Number,title:\"Label Font Weight\"},inputFontWeight:{type:ControlType.Number,title:\"Input Font Weight\"},labelSpacing:{type:ControlType.Number,title:\"Label Spacing\"},redirectUrl:{type:ControlType.String,title:\"Redirect URL\"},actionType:{type:ControlType.Enum,title:\"Action Type\",options:[\"verify\",\"rate\",\"favorite\",\"none\"],optionTitles:[\"Verify Church\",\"Rate Church\",\"Favorite Church\",\"None\"]}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SignUpForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"wTAGG,SAAwB,EAAW,CAAC,sBAAoB,mBAAiB,sBAAoB,aAAW,OAAK,WAAS,aAAW,cAAY,kBAAgB,mBAAiB,uBAAqB,iBAAe,eAAa,eAAa,gBAAc,aAAW,gBAAc,kBAAgB,kBAAgB,eAAa,cAAY,cAAY,CAAC,GAAK,CAAC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