1import{r as u,j as r,z as q,s as L,a as Q}from"./playbook-DzR_ry6Q.js";import{P as X}from"./PageTitle-DSuujEOz.js";import{u as Z}from"./useURLParams-CIlhPcPz.js";import{C as ee}from"./CookieManager-BG6m6gTg.js";import{i as P}from"./miscUtils-DVxAfiYU.js";import{a as re}from"./useCanonical-Cd4wv_wu.js";import{u as se}from"./useMetaTag-DmfxVqnn.js";import{E as ae}from"./EmailInput-R2-O3SWR.js";import{h as te,W as U,H as N,r as F}from"./AppUpdateMonitor-Bn2pSfA6.js";import{E as k}from"./errorTypes-C-KT-Ibe.js";import{u as oe}from"./useValidatedForm-Des8iXVn.js";import{p as ne}from"./apiErrorUtils-BYpMQDYN.js";import{i as ie}from"./validatorUtils-BP163Jh0.js";import{u as le,a as ce}from"./useRecaptcha-uyABUfQ2.js";import{e as me,o as de}from"./app-public-BF3VXhlA.js";import{u as pe}from"./useMutation-BauU2Qu1.js";import"./loadScript-HSAzlTCA.js";import"./TwitterMajor-Df5iUS11.js";import"./LinkedinMajor-jXmX5JLG.js";import"./utils-C3Uzq3hM.js";const ue="/api/SignupApi",ge=({formData:s})=>te.post(`${ue}/Join`,s),he=({options:s}={})=>pe(e=>ge({formData:e}),s),b="joinFormData",fe=()=>{const s={name:"",email:"",signUpAs:"",returnUrl:"",organizationId:"",sport:""};try{const e=sessionStorage.getItem(b);return e?JSON.parse(e):s}catch{return s}},xe=(s,e={})=>{try{sessionStorage.setItem(b,JSON.stringify({name:s.name,email:s.email,signUpAs:s.signUpAs,...e}))}catch{}},we=()=>{try{sessionStorage.removeItem(b)}catch{}},ye=s=>{const e={};return!s.name||s.name.trim()===""?e.name="Please enter your name":/http:|https:|www\./i.test(s.name)&&(e.name=r.jsxs(r.Fragment,{children:["Try again or"," ",r.jsx("a",{target:"_blank",rel:"noopener noreferrer",href:"https://support.fieldlevel.com/en/articles/880327-contact-us",className:"underline",children:"contact support"}),"."]})),s.email||(e.email="Please enter your email"),s.email&&!ie(s.email)&&(e.email="Please enter a valid email"),s.password||(e.password="Please enter a password"),s.password&&s.password.length<6&&(e.password="Password must be at least 6 characters"),s.signUpAs||(e.signUpAs="Please select who you are"),e},Ue=({initialEmail:s,initialName:e,initialSignUpAs:f,returnUrl:o,organizationId:l,sport:m})=>{const[n,c]=u.useState({}),[x,w]=u.useState(!1),[A,C]=u.useState(null),{mutateAsync:T,isLoading:v}=he(),{executeRecaptcha:R}=le(),z=ce(),E=me(),j=de();u.useEffect(()=>{we()},[]);const J=u.useMemo(()=>{const a=fe();return{name:e||a.name||"",email:s||a.email||"",password:"",signUpAs:f||a.signUpAs||"",organizationId:l||a.organizationId||"",sport:m||a.sport||""}},[s,e,f,l,m]),O=a=>{const p={token:a};return o&&(p.returnUrl=o),p},B=a=>{const p=t=>{if(t.IsFamilyMemberEmail&&t.OneTimeCodeToken){xe(a,{returnUrl:o,organizationId:l,sport:m});const h=O(t.OneTimeCodeToken);z.oneTimeCode({searchParams:h}).go();return}if(t.RedirectUrl){window.location.assign(t.RedirectUrl);return}w(!1)},K=t=>{w(!1);const h=t.data;if(h?.errors){const $=ne(h.errors);c($);return}switch(C(null),h?.errorCode){case k.User.EmailAlreadyExists:C(a.email);break;case k.Form.RecaptchaFailed:c({general:"Sorry, something went wrong. Please try again."});break;default:F("Join :: Unexpected signup failure",t),c({general:"Sorry, something went wrong. Please try again."});break}},Y=async()=>{try{return await R("signup")}catch(t){return F("Join :: reCAPTCHA failed",t),null}};(async()=>{w(!0);const t=await Y();if(!t){w(!1),c({general:"Sorry, something went wrong."});return}await T({Name:a.name,Email:a.email,Password:a.password,SignUpAs:a.signUpAs,RecaptchaToken:t,ReturnUrl:o,OrganizationId:l?parseInt(l,10):null,Sport:m},{onSuccess:p,onError:K})})()},{values:i,errors:g,handleChange:y,handleSubmit:M}=oe(B,ye,J),d=x||v;u.useEffect(()=>{c({}),C(null)},[i.name,i.email,i.password,i.signUpAs]);const D=n.name||g.name,V=n.email||g.email,_=n.password||g.password,W=n.signupas||g.signUpAs,S=n.general,H=!P(g)||!P(n),G=E.signIn({searchParams:{returnUrl:o}}).wiredLinkProps,I=A?E.signIn({searchParams:{email:A,returnUrl:o}}).wiredLinkProps:null;return r.jsxs(r.Fragment,{children:[r.jsx("form",{onSubmit:M,noValidate:!0,children:r.jsxs("div",{className:"flex flex-col gap-6",children:[r.jsx(q,{placeholder:{label:"I am a...",value:""},options:[{label:"I am a coach",value:"Coach"},{label:"I am an athlete",value:"Athlete"}],size:"large",name:"signUpAs",value:i.signUpAs,error:W,onChange:(a,p)=>y(a,p),disabled:d}),r.jsx(L,{name:"name",type:"text",placeholder:"First and Last Name",size:"large",attributes:{autoComplete:"name",autoCapitalize:"words",autoCorrect:"off"},onChange:y,disabled:d,value:i.name,error:D}),r.jsxs("div",{children:[r.jsx(ae,{name:"email",placeholder:"Email",size:"large",attributes:{autoComplete:"email",autoCapitalize:"off",autoCorrect:"off"},onChange:y,disabled:d,value:i.email,error:V}),A&&I&&r.jsxs("div",{className:"text-body text-critical p-2",children:["This email is already registered."," ",r.jsx(U,{...I,className:"text-muted underline",children:"Log in"})]})]}),r.jsx(L,{name:"password",type:"password",placeholder:"Password",size:"large",attributes:{autoComplete:"new-password",autoCapitalize:"off",autoCorrect:"off"},onChange:y,disabled:d,value:i.password,error:_}),S&&r.jsx("div",{className:"text-critical text-body-sm",children:S}),r.jsxs("div",{children:[r.jsx(Q,{variant:"primary",size:"large",disabled:d,submit:!0,fullWidth:!0,children:d?"Creating Account...":"Sign Up"}),H&&r.jsx("div",{className:"ml-1 text-critical",children:"Please correct the highlighted errors"})]}),r.jsxs("div",{className:"text-center text-body-sm text-muted",children:["By signing up, you agree to our"," ",r.jsx(U,{reloadPage:N(),...j.policies({pathParams:{policy:"terms"}}).wiredLinkProps,className:"text-muted underline",children:"Terms"})," ","and"," ",r.jsx(U,{reloadPage:N(),...j.policies({pathParams:{policy:"privacy"}}).wiredLinkProps,className:"text-muted underline",children:"Privacy Policy"}),"."]})]})}),r.jsxs("div",{className:"text-center text-body-lg border-t border-muted py-8",children:["Already have an account? ",r.jsx(U,{...G,children:"Log In"})]})]})},Ve=()=>{const s=x=>x?.toLowerCase()==="coach"?"Coach":x?.toLowerCase()==="athlete"?"Athlete":"",{search:e}=Z();re(),se({name:"robots",content:"noindex",isEnabled:!P(e)}
1),e.returnUrl&&ee.setFLReturnUrl(e.returnUrl);const f=e.returnUrl||"",o=e.email||"",l=e.name||e.Name||"",m=e.targetId,n=e.sport,c=e.isCoach?"Coach":e.isAthlete?"Athlete":s(e.signUpAs);return r.jsxs(r.Fragment,{children:[r.jsx(X,{title:"Join FieldLevel"}),r.jsxs("div",{className:"w-full min-w-[300px] max-w-[400px] sm:min-w-[400px] m-auto flex flex-col gap-8",children:[r.jsx("h1",{className:"text-[36px] font-[600]",children:"Sign Up for Free"}),r.jsx(Ue,{initialEmail:o,initialName:l,initialSignUpAs:c,returnUrl:f,organizationId:m,sport:n})]})]})};export{Ve as default}; 2//# sourceMappingURL=Join-Dxh0t9kD.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.