import{c as h,r as R,o as u,b as d,d as l,w as V,k as b,m as A,v as S,n as U,e as i,h as y,f as c,t as x,g as v,i as p,j as q,l as k,_}from"./index-9538feb4.js";const L={class:"min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8"},T={class:"max-w-md w-full space-y-8"},B={class:"rounded-md shadow-sm space-y-4"},D={class:"flex gap-2"},K=["disabled","onKeydown"],O={key:0,class:"mt-2 rounded-md bg-blue-50 p-3"},j={class:"text-sm font-medium text-blue-800"},z={class:"text-xs text-blue-600 mt-0.5"},M={class:"flex gap-3 mt-1"},$={key:0,class:"text-xs text-green-600"},F={key:1,class:"text-xs text-blue-600"},I={key:1,class:"mt-1 text-sm text-red-600"},J={key:0,class:"rounded-md bg-red-50 p-4"},G={class:"text-sm text-red-700"},H={key:1,class:"rounded-md bg-green-50 p-4"},Q={class:"text-sm text-green-700"},W={class:"text-center"},Z={__name:"Register",setup(X){const t=p(!1),o=p(""),g=p(""),f=p(!1),m=p(""),n=p(null),e=q({voen:"",fullName:"",email:"",password:"",confirmPassword:""}),N=h({url:"cloud_portal.api.voen.lookup",onSuccess(a){f.value=!1,a.success?(n.value=a,m.value="",e.fullName||(e.fullName=a.name)):(n.value=null,m.value=a.message||"Organization not found")},onError(a){var s;f.value=!1,n.value=null,m.value=((s=a.messages)==null?void 0:s[0])||a.message||"Lookup failed"}});function w(){e.voen&&(f.value=!0,m.value="",n.value=null,N.fetch({voen:e.voen}))}const P=h({url:"cloud_portal.api.auth.register_user",onSuccess(a){t.value=!1,a.success?(g.value="Account created! Redirecting...",o.value="",setTimeout(()=>{window.location.href="/portal/sites"},500)):o.value=a.message||"Registration failed"},onError(a){var s;t.value=!1,o.value=((s=a.messages)==null?void 0:s[0])||a.message||"Registration failed"}});function C(){if(!e.voen){o.value="Please enter your VOEN (ИНН)";return}if(!e.fullName||!e.email||!e.password){o.value="Please fill in all fields";return}if(e.password.length<6){o.value="Password must be at least 6 characters";return}if(e.password!==e.confirmPassword){o.value="Passwords do not match";return}o.value="",g.value="",t.value=!0,P.fetch({full_name:e.fullName,email:e.email,password:e.password,voen:e.voen})}return(a,s)=>{const E=R("router-link");return u(),d("div",L,[l("div",T,[s[9]||(s[9]=l("div",null,[l("h2",{class:"mt-6 text-center text-3xl font-extrabold text-gray-900"}," Cloud Portal "),l("p",{class:"mt-2 text-center text-sm text-gray-600"}," Create your account ")],-1)),l("form",{class:"mt-8 space-y-6",onSubmit:V(C,["prevent"])},[l("div",B,[l("div",null,[s[6]||(s[6]=l("label",{class:"block text-sm font-medium text-gray-700 mb-1"},[b(" VOEN (ИНН) "),l("span",{class:"text-red-500"},"*")],-1)),l("div",D,[A(l("input",{type:"text","onUpdate:modelValue":s[0]||(s[0]=r=>e.voen=r),placeholder:"0000000000",disabled:t.value||f.value,class:"flex-1 rounded-md border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:bg-gray-100",onKeydown:U(V(w,["prevent"]),["enter"])},null,40,K),[[S,e.voen]]),i(c(k),{type:"button",variant:"subtle",loading:f.value,disabled:!e.voen||t.value,onClick:w},{default:y(()=>[...s[5]||(s[5]=[b(" Lookup ",-1)])]),_:1},8,["loading","disabled"])]),n.value?(u(),d("div",O,[l("p",j,x(n.value.name),1),l("p",z,x(n.value.organization_type),1),l("div",M,[n.value.active?(u(),d("span",$,"Active")):v("",!0),n.value.vat_payer?(u(),d("span",F,"VAT Payer")):v("",!0)])])):v("",!0),m.value?(u(),d("p",I,x(m.value),1)):v("",!0)]),i(c(_),{label:"Full Name",type:"text",modelValue:e.fullName,"onUpdate:modelValue":s[1]||(s[1]=r=>e.fullName=r),placeholder:"John Doe",disabled:t.value,required:""},null,8,["modelValue","disabled"]),i(c(_),{label:"Email",type:"email",modelValue:e.email,"onUpdate:modelValue":s[2]||(s[2]=r=>e.email=r),placeholder:"you@example.com",disabled:t.value,required:""},null,8,["modelValue","disabled"]),i(c(_),{label:"Password",type:"password",modelValue:e.password,"onUpdate:modelValue":s[3]||(s[3]=r=>e.password=r),placeholder:"Password (min 6 characters)",disabled:t.value,required:""},null,8,["modelValue","disabled"]),i(c(_),{label:"Confirm Password",type:"password",modelValue:e.confirmPassword,"onUpdate:modelValue":s[4]||(s[4]=r=>e.confirmPassword=r),placeholder:"Confirm password",disabled:t.value,required:""},null,8,["modelValue","disabled"])]),o.value?(u(),d("div",J,[l("p",G,x(o.value),1)])):v("",!0),g.value?(u(),d("div",H,[l("p",Q,x(g.value),1)])):v("",!0),l("div",null,[i(c(k),{type:"submit",variant:"solid",class:"w-full",loading:t.value},{default:y(()=>[...s[7]||(s[7]=[b(" Create Account ",-1)])]),_:1},8,["loading"])]),l("div",W,[i(E,{to:{name:"Login"},class:"text-sm text-blue-600 hover:text-blue-500"},{default:y(()=>[...s[8]||(s[8]=[b(" Already have an account? Sign in ",-1)])]),_:1})])],32)])])}}};export{Z as default};
//# sourceMappingURL=Register-1898e04e.js.map
