1import{b as J,c as oe}from"./chunk-FVX33YKK.js";import{vb as $,wb as te}from"./chunk-52S7N7V6.js";import"./chunk-UD5EBHOY.js";import{d as j,e as ie}from"./chunk-HHWCKN2Y.js";import{F as ee,c as A,d as k}from"./chunk-UR66OFCA.js";import{I as P,N as Y,R as q,j as T,k as N,ma as Z,p as X}from"./chunk-YRXPJKGP.js";import"./chunk-244O5MFV.js";import{a as R,g as Q}from"./chunk-AFRE35PB.js";import{D as O,E as H,d as D,f as c,h as F,i as G,j as B,l as h,n as I,r as U,s as V}from"./chunk-3WLKQOFJ.js";import{Bb as m,Db as d,Ib as x,J as w,Jb as o,Kb as n,Lb as f,Q as _,Vb as b,Yb as C,ab as a,de as M,ee as L,id as E,ie as W,lc as r,mb as v,mc as S,na as K,nc as y,va as g}from"./chunk-MRH42WUF.js";import{f as z}from"./chunk-I7AXXHAK.js";function ne(e,i){e&1&&(o(0,"span",5),r(1,"Name is required."),n())}function re(e,i){e&1&&r(0," Email is required. ")}function ae(e,i){e&1&&r(0," Enter a valid email address. ")}function se(e,i){if(e&1&&(o(0,"span",5),m(1,re,1,0)(2,ae,1,0),n()),e&2){let s=C();a(),d(s.form.controls.email.errors.required?1:s.form.controls.email.errors.email?2:-1)}}function le(e,i){e&1&&r(0," Password is required. ")}function me(e,i){e&1&&r(0," Password must be at least 8 characters. ")}function de(e,i){if(e&1&&(o(0,"span",5),m(1,le,1,0)(2,me,1,0),n()),e&2){let s=C();a(),d(s.form.controls.password.errors.required?1:s.form.controls.password.errors.minlength?2:-1)}}function ce(e,i){e&1&&(o(0,"span",5),r(1,"Passwords do not match."),n())}function pe(e,i){if(e&1&&(o(0,"span",10),r(1),n()),e&2){let s=C();a(),S(s.errorMessage)}}function ue(e){let i=e.get("password")?.value,s=e.get("confirmPassword")?.value;return i===s?null:{passwordMismatch:!0}}var Ne,fe=z(()=>{E();H();W();X();K();Z();Y();ee();ie();Q();te();oe();E();H();Ne=(()=>{let i=class i{constructor(){this.apiClient=g(R),this.router=g(M),this.store=g(T),this.form=new B({name:new h("",[c.required]),email:new h("",[c.required,c.email]),password:new h("",[c.required,c.minLength(8)]),confirmPassword:new h("",[c.required])},{validators:ue}),this.isLoading=!1,this.errorMessage=null,this.subscription=null}onSubmit(){if(this.form.invalid){this.form.markAllAsTouched();return}this.isLoading=!0,this.errorMessage=null;let{name:p,email:l,password:t}=this.form.value;this.apiClient.post("/auth/register",{name:p,email:l,password:t},{withCredentials:!0},{isAuth:!0}).subscribe({next:()=>this.autoLogin(l,t),error:u=>{this.isLoading=!1,u.status===409?this.errorMessage="An account with this email already exists.":u.status===400?this.errorMessage=u.error?.message??"Invalid details. Please check your input.":u.status===0?this.errorMessage="Unable to reach the server. Please check your connection.":this.errorMessage="Registration failed. Please try again."}})}autoLogin(p,l){this.apiClient.post("/auth/login",{email:p,password:l},{withCredentials:!0},{isAuth:!0}).subscribe({next:()=>{this.store.dispatch(new q),this.subscription=this.store.pipe(N(P),w(t=>!!t?._id),_(1)).subscribe(t=>{this.isLoading=!1,t.activeRole&&j.includes(t.activeRole)?this.router.navigate([`/${k}`]):this.router.navigate([`/${A}`])})},error:()=>{this.isLoading=!1,this.router.navigate(["/login"])}})}ngOnDestroy(){this.subscription?.unsubscribe()}};i.\u0275fac=function(l){return new(l||i)},i.\u0275cmp=v({type:i,selectors:[["app-register"]],decls:25,vars:8,consts:[[1,"text-3xl","font-semibold","text-center","text-[#1B2559]","mb-2"],[1,"text-center","text-gray-500","mb-8"],[1,"flex","flex-col","gap-3",3,"ngSubmit","formGroup"],[1,"flex","flex-col","gap-1"],["formControlName","name","type","text","placeholder","Enter your name","autocomplete","name",1,"w-full","px-4","py-3","rounded-xl","bg-[#6571C4]","text-white","placeholder-white/80","focus:outline-none","focus:ring-2","focus:ring-indigo-400"],[1,"text-red-500","text-xs","px-1"],["formControlName","email","type","email","placeholder","Enter email address","autocomplete","email",1,"w-full","px-4","py-3","rounded-xl","bg-[#6571C4]","text-white","placeholder-white/80","focus:outline-none","focus:ring-2","focus:ring-indigo-400"],["formControlName","password","placeholder","Create a password","autocomplete","new-password"],["formControlName","confirmPassword","placeholder","Confirm your password","autocomplete","new-password"],["type","submit",1,"w-full","py-3","mt-2","rounded-lg","bg-[#B8C4E8]","text-[#1B2559]","font-medium","hover:bg-[#a8b4d8]","transition-colors","disabled:opacity-60",3,"disabled"],[1,"text-red-500","text-xs","text-center"],[1,"text-center","text-sm","text-gray-500","mt-6"],["routerLink","/login",1,"text-[#1B2559]","text-sm","underline"]],template:function(l,t){l&1&&(o(0,"app-auth-layout")(1,"h2",0),r(2,"Create account"),n(),o(3,"p",1),r(4,"Join LearnCove"),n(),o(5,"form",2),b("ngSubmit",function(){return t.onSubmit()}),o(6,"div",3),f(7,"input",4),m(8,ne,2,0,"span",5),n(),o(9,"div",3),f(10,"input",6),m(11,se,3,1,"span",5),n(),o(12,"div",3),f(13,"app-password-input",7),m(14,de,3,1,"span",5),n(),o(15,"div",3),f(16,"app-password-input",8),m(17,ce,2,0,"span",5),n(),o(18,"button",9),r(19),n(),m(20,pe,2,1,"span",10),n(),o(21,"p",11),r(22," Already have an account? "),o(23,"a",12),r(24,"Sign in"),n()()()),l&2&&(a(5),x("formGroup",t.form),a(3),d(t.form.controls.name.touched&&(t.form.controls.name.errors!=null&&t.form.controls.name.errors.required)?8:-1),a(3),d(t.form.controls.email.touched&&t.form.controls.email.errors?11:-1),a(3),d(t.form.controls.password.touched&&t.form.controls.password.errors?14:-1),a(3),d(t.form.controls.confirmPassword.touched&&(t.form.errors!=null&&t.form.errors.passwordMismatch)?17:-1),a(),x("disabled",t.isLoading),a(),y(" ",t.isLoading?"Creating account...":"Create account"," "),a(),d(t.errorMessage?20:-1))},dependencies:[O,I,D,F,G,U,V,L,$,J],encapsulation:2});let e=i;return e})()});fe();export{Ne as RegisterComponent};
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.