import{r as s,h as t}from"./p-9f21f85f.js";import{T as r}from"./p-968ee2ec.js";import{V as i}from"./p-56463912.js";import{V as e}from"./p-ad6da9fe.js";import"./p-31e77e7b.js";import"./p-105f7627.js";import"./p-35c7f358.js";const o=s=>[new r("firstName","","First name","").setValue(s.firstName).setErrorTitle("Name").require(),new r("lastName","","Last name","").setValue(s.lastName).setErrorTitle("Surname").require(),new r("email","","Email","","email").setValue(s.email).setErrorTitle("Email").addInterceptor("onSubmit",new i).require(),new r("password","","Password","","password").setErrorTitle("Password").addInterceptor("onSubmit",new e(6,24)).require()];function a(s){if(s)return 401===s.status?["Credentials are not valid."]:["Unexpected error."]}const m=class{constructor(t){s(this,t),this.data={},this.onSubmit=s=>{const t=s.detail.values,{email:r,firstName:i,lastName:e,password:o}=t;this.progressing=!0,this.api.register(r,i,e,o).then(this.onSucceed,this.onError)},this.onSucceed=s=>{this.api.addAuthInterceptor(s.jwt),this.progressing=!1,this.onRegister&&this.onRegister(s),this.redirect&&(window.location=this.redirect)},this.onError=s=>{this.error=s,this.progressing=!1}}render(){const{data:s,error:r,progressing:i}=this;return t("doldurma-form",{fields:o(s),onSubmit:this.onSubmit,submitButtonLabel:"Register",progressing:i,formErrors:a(r)})}};export{m as kimlik_register_form}