1import{d as z,aB as F,aC as L,u as Y,a as $,b as d,j as c,k as e,v as s,n as p,F as ue,p as H,q as N,aE as de,aG as J,P as ce,o as v,aQ as pe,aM as M,H as O,aP as me,aN as fe,aO as ge,aS as he,aR as ve,l as w,aI as we,aJ as Q,aK as ye,aL as be,_ as xe,m as T,K as Me,U as Z,J as K,aU as Oe,aW as Ae,aX as _e,b2 as Ce,b3 as A,b4 as Ee,Q as g,aF as ke,b9 as X,ba as j,b6 as Se,b0 as Ue,b1 as R}from"./DUququmF.js";import{_ as Te}from"./CNCXAscC.js";import{u as Ie}from"./BVc1Z-A8.js";import"./BERE3zmT.js";import"./9WbiuyM6.js";import"./CQXioT8-.js";import"./iLXYiTCR.js";import"./_elIokNk.js";import"./D76aULLx.js";import"./9LluSWt2.js";const Pe={class:"universal-card flex w-full max-w-[27rem] flex-col gap-6 border border-solid border-surface-5 !p-6"},$e={class:"mx-auto text-center text-2xl font-semibold text-contrast"},Ne={class:"flex flex-col gap-2.5"},Re={class:"flex flex-col gap-2.5"},qe={for:"email",hidden:""},Le={for:"password",hidden:""},We={key:0,class:"m-0 text-center"},Ve={class:"mx-auto flex flex-wrap items-center justify-start gap-2 text-center"},Ge=z({__name:"SignUp",props:de({redirectTarget:{default:""},showOtherOptions:{type:Boolean,default:!1},routeQuery:{default:()=>({})},onToggleOtherOptions:{type:Function,default:()=>{}},onContinueWithEmail:{type:Function,default:()=>{}}},{email:{default:""},emailModifiers:{},password:{default:""},passwordModifiers:{}}),emits:["update:email","update:password"],setup(l){const y=F(l,"email"),b=F(l,"password"),_=L(J,null),m=f=>{_.value=f},{formatMessage:r}=Y(),u=Z({signUpWithTitle:{id:"auth.sign-up.title.sign-up-with",defaultMessage:"Create an Account"},continueWithProvider:{id:"auth.continue-with-provider",defaultMessage:"Continue with {provider}"},legalDisclaimer:{id:"auth.sign-up.legal-dislaimer",defaultMessage:"By creating an account, you agree to Modrinth's <terms-link>Terms</terms-link> and <privacy-policy-link>Privacy Policy</privacy-policy-link>."},alreadyHaveAccountLabel:{id:"auth.sign-up.sign-in-option.title",defaultMessage:"Already have an account?"},continueWithEmail:{id:"auth.sign-up.continue-with-email",defaultMessage:"Continue with Email"},showFewerOptions:{id:"auth.sign-up.show-fewer-options",defaultMessage:"Show fewer options"},showOtherOptions:{id:"auth.sign-up.show-other-options",defaultMessage:"Show other options"}});return(f,n)=>{const C=ce;return v(),$("div",Pe,[d("div",$e,c(e(r)(e(u).signUpWithTitle)),1),d("section",Ne,[s(e(O),{href:e(M)("google",l.redirectTarget),onClick:n[0]||(n[0]=i=>m("google"))},{default:p(()=>[s(e(pe)),d("span",null,c(e(r)(e(u).continueWithProvider,{provider:"Google"})),1)]),_:1},8,["href"]),s(e(O),{href:e(M)("microsoft",l.redirectTarget),onClick:n[1]||(n[1]=i=>m("microsoft"))},{default:p(()=>[s(e(me)),d("span",null,c(e(r)(e(u).continueWithProvider,{provider:"Microsoft"})),1)]),_:1},8,["href"]),s(e(O),{href:e(M)("discord",l.redirectTarget),onClick:n[2]||(n[2]=i=>m("discord"))},{default:p(()=>[s(e(fe)),d("span",null,c(e(r)(e(u).continueWithProvider,{provider:"Discord"})),1)]),_:1},8,["href"]),l.showOtherOptions?(v(),$(ue,{key:0},[s(e(O),{href:e(M)("github",l.redirectTarget),onClick:n[3]||(n[3]=i=>m("github"))},{default:p(()=>[s(e(ge)),d("span",null,c(e(r)(e(u).continueWithProvider,{provider:"GitHub"})),1)]),_:1},8,["href"]),s(e(O),{href:e(M)("gitlab",l.redirectTarget),onClick:n[4]||(n[4]=i=>m("gitlab"))},{default:p(()=>[s(e(he)),d("span",null,c(e(r)(e(u).continueWithProvider,{provider:"GitLab"})),1)]),_:1},8,["href"]),s(e(O),{href:e(M)("steam",l.redirectTarget),onClick:n[5]||(n[5]=i=>m("steam"))},{default:p(()=>[s(e(ve)),d("span",null,c(e(r)(e(u).continueWithProvider,{provider:"Steam"})),1)]),_:1},8,["href"])],64)):H("",!0),d("button",{class:"mx-auto -mb-3 bg-transparent pt-1 text-center text-base font-semibold text-secondary transition-all hover:text-primary",onClick:n[6]||(n[6]=i=>l.onToggleOtherOptions())},c(l.showOtherOptions?e(r)(e(u).showFewerOptions):e(r)(e(u).showOtherOptions)),1)]),n[10]||(n[10]=d("div",{class:"h-px w-full bg-surface-5"},null,-1)),d("section",Re,[d("label",qe,c(e(r)(e(w).emailLabel)),1),s(e(Q),{id:"email",modelValue:y.value,"onUpdate:modelValue":n[7]||(n[7]=i=>y.value=i),icon:e(we),type:"email",autocomplete:"email",placeholder:e(r)(e(w).emailLabel),"wrapper-class":"w-full"},null,8,["modelValue","icon","placeholder"]),d("label",Le,c(e(r)(e(w).passwordLabel)),1),s(e(Q),{id:"password",modelValue:b.value,"onUpdate:modelValue":n[8]||(n[8]=i=>
1b.value=i),icon:e(ye),type:"password",autocomplete:"new-password",placeholder:e(r)(e(w).passwordLabel),"wrapper-class":"w-full"},null,8,["modelValue","icon","placeholder"]),s(e(xe),{type:"colored",color:"brand",class:"!w-full",disabled:!y.value||!b.value,onClick:n[9]||(n[9]=i=>l.onContinueWithEmail())},{default:p(()=>[N(c(e(r)(e(u).continueWithEmail))+" ",1),s(e(be))]),_:1},8,["disabled"]),l.routeQuery.launcher?H("",!0):(v(),$("p",We,[s(e(Me),{"message-id":e(u).legalDisclaimer},{"terms-link":p(({children:i})=>[s(C,{to:"/legal/terms",class:"text-link"},{default:p(()=>[(v(),T(K(()=>i)))]),_:2},1024)]),"privacy-policy-link":p(({children:i})=>[s(C,{to:"/legal/privacy",class:"text-link"},{default:p(()=>[(v(),T(K(()=>i)))]),_:2},1024)]),_:1},8,["message-id"])])),d("div",Ve,[N(c(e(r)(e(u).alreadyHaveAccountLabel))+" ",1),s(C,{class:"mr-1 text-link",to:{path:"/auth/sign-in",query:l.routeQuery}},{default:p(()=>[N(c(e(r)(e(w).signInButton)),1)]),_:1},8,["to"])])])])}}}),q=39,De=10,Be=10,et=z({__name:"sign-up",setup(l){const y=a=>{const t=Array.isArray(a)?a[0]:a;return typeof t=="string"?t:""},b=a=>{const t=a;return typeof t?.data?.description=="string"?t.data.description:a instanceof Error?a.message:String(a)},_=Oe(),{addNotification:m}=Ae(),{formatMessage:r}=Y(),u=Z({title:{id:"auth.sign-up.title",defaultMessage:"Sign Up"},ageRequirementWarningTitle:{id:"auth.sign-up.age-requirement.warning-title",defaultMessage:"Age requirement"},under13HelperText:{id:"auth.create-account.date-of-birth.under13-helper",defaultMessage:"You cannot create an account at Modrinth unless you are over 13 years old."}});_e({title:()=>`${r(u.title)} - Modrinth`});const f=Ee(),n=L(J,null,void 0,{initOnMounted:!0}),C=L(ke,null,void 0,{initOnMounted:!0}),i=y(f.query.redirect),I=g(!1),W=g(!1),V=g(null),ee=a=>{V.value=a??null},te=()=>{I.value=!I.value},{data:ae}=Ce({queryKey:["auth-globals"],queryFn:async()=>{try{return await _.labrinth.globals_internal.get()}catch(a){return console.error("Error fetching globals:",a),{captcha_enabled:!0,tax_compliance_thresholds:{}}}}}),h=g(""),E=g(""),P=g(""),x=g(""),k=g(""),S=g(!1);async function ne(){n.value=null,C.value=null,X();try{const a=await oe();k.value="",x.value=a,W.value=!0}catch(a){m({title:r(w.errorNotificationTitle),text:b(a),type:"error"})}j()}function G(a){const[t=""]=a.trim().toLowerCase().split("@");return(t.replace(/[^a-zA-Z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"user").slice(0,q)}async function oe(){const a=G(h.value);for(let t=0;t<=De;t++){const o=re(a,t);try{return await D(o),o}catch(U){if(!B(U))throw U}}return await ie()}function re(a,t){if(t===0)return a;const o=String(t),U=Math.max(1,q-o.length);return`${a.slice(0,U)}${o}`}function se(){return`user_${`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`}`.slice(0,q)}async function ie(){for(let a=0;a<Be;a++){const t=se();try{return await D(t),t}catch(o){if(!B(o))throw o}}throw new Error("Unable to find an available username. Please choose one manually.")}async function D(a){await _.labrinth.auth_v2.validateCreateAccount({username:a,password:E.value,email:h.value})}function B(a){const t=a;return(t?.data?.error??t?.v1Error?.error??t?.responseData?.error)==="username_taken"}async function le(a){X();try{const t=await _.labrinth.auth_v2.createAccount({username:x.value.trim()||G(h.value),password:E.value,email:h.value,challenge:k.value,sign_up_newsletter:S.value,account_consent:a});if(await Se(t.session),await Ie(),Ue(),f.query.launcher){await R({path:"/auth/sign-in",query:f.query});return}f.query.redirect?await R(y(f.query.redirect)):await R(`/user/${x.value}`)}catch(t){m({title:r(w.errorNotificationTitle),text:b(t),type:"error"}),V.value?.reset?.()}j()}return(a,t)=>e(W)?(v(),T(Te,{key:1,"date-of-birth":e(P),"onUpdate:dateOfBirth":t[2]||(t[2]=o=>A(P)?P.value=o:null),username:e(x),"onUpdate:username":t[3]||(t[3]=o=>A(x)?x.value=o:null),token:e(k),"onUpdate:token":t[4]||(t[4]=o=>A(k)?k.value=o:null),subscribe:e(S),"onUpdate:subscribe":t[5]||(t[5]=o=>A(S)?S.value=o:null),globals:e(ae),"on-complete-sign-up":le,"on-set-captcha-ref":ee},null,8,["date-of-birth","username","token","subscribe","globals"])):(v(),T(Ge,{key:0,email:e(h),"onUpdate:email":t[0]||(t[0]=o=>A(h)?h.value=o:null),password:e(E),"onUpdate:password":t[1]||(t[1]=o=>A(E)?E.value=o:null),"redirect-target":e(i),"show-other-options":e(I),"route-query":e(f).query,"on-toggle-other-options":te,"on-continue-with-email":ne},null,8,["email","password","redirect-target","show-other-options","route-query"]))}});
1export{et as default};
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.