import{u as C,a as U,a1 as S,c as y,a0 as K,d as _,j as a,e as n,k as E,L,l as p,m as w,f as s,t as u,i as g,C as b,p as D,H as V}from"./app-D4Udf6Mm.js";import{F as v}from"./Form-BGrUTood.js";import{_ as R}from"./SettingTabs-D1fgIcyl.js";/*! 2FAuth version 5.4.1 - Copyright (c) 2024 Bubka - https://github.com/Bubka/2FAuth */const H={class:"options-tabs"},M={key:0,class:"notification is-warning"},W={key:1,class:"notification is-info has-text-centered"},j=["innerHTML"],z={class:"title is-4 has-text-grey-light"},I=["disabled"],q={class:"title is-4 pt-6 has-text-grey-light"},G=["disabled"],J={class:"title is-4 pt-6 has-text-danger"},O={class:"field is-size-7-mobile"},Q={class:"block"},X=["disabled"],oe={__name:"Account",setup(Y){const c=L("2fauth"),d=C(),i=U(),F=D(),x=S(c.prefix+"returnTo","accounts"),l=y(new v({name:d.name,email:d.email,password:""})),t=y(new v({currentPassword:"",password:"",password_confirmation:""})),m=y(new v({password:""}));function T(r){l.put("/user",{returnError:!0}).then(e=>{d.$patch({name:e.data.name,email:e.data.email,isAdmin:e.data.is_admin}),i.success({text:V("auth.forms.profile_saved")})}).catch(e=>{e.response.status===400?i.alert({text:e.response.data.message}):e.response.status!==422&&i.error(e.response)})}function P(r){t.patch("/user/password",{returnError:!0}).then(e=>{t.password="",t.formPassword="",t.password_confirmation="",i.success({text:e.data.message})}).catch(e=>{e.response.status===400?i.alert({text:e.response.data.message}):e.response.status!==422&&i.error(e.response)})}function $(r){confirm(V("auth.confirm.delete_account"))&&m.delete("/user",{returnError:!0}).then(e=>{i.success({text:V("auth.forms.user_account_successfully_deleted")}),F.push({name:"register"})}).catch(e=>{e.response.status===400?i.alert({text:e.response.data.message}):e.response.status!==422&&i.error(e.response)})}return K(r=>{!r.name.startsWith("settings.")&&r.name==="login"&&i.clear()}),(r,e)=>{const f=p("FormField"),h=p("FormButtons"),B=p("FormPasswordField"),N=p("FormWrapper"),k=p("ButtonBackCloseCancel"),A=p("VueFooter");return w(),_("div",null,[a(R,{activeTab:"settings.account"},null,8,["activeTab"]),n("div",H,[a(N,null,{default:E(()=>[s(d).isAdmin?(w(),_("div",M,u(r.$t("settings.you_are_administrator")),1)):g("",!0),s(d).oauth_provider?(w(),_("div",W,u(r.$t("settings.account_linked_to_sso_x_provider",{provider:s(d).oauth_provider})),1)):g("",!0),n("form",{onSubmit:b(T,["prevent"]),onKeydown:e[3]||(e[3]=o=>s(l).onKeydown(o))},[s(c).config.proxyAuth?(w(),_("div",{key:0,class:"notification is-warning has-text-centered",innerHTML:r.$t("auth.user_account_controlled_by_proxy")},null,8,j)):g("",!0),n("h4",z,u(r.$t("settings.profile")),1),n("fieldset",{disabled:s(c).config.proxyAuth||s(d).oauth_provider},[a(f,{modelValue:s(l).name,"onUpdate:modelValue":e[0]||(e[0]=o=>s(l).name=o),fieldName:"name",fieldError:s(l).errors.get("name"),label:"auth.forms.name",maxLength:255,autofocus:""},null,8,["modelValue","fieldError"]),a(f,{modelValue:s(l).email,"onUpdate:modelValue":e[1]||(e[1]=o=>s(l).email=o),fieldName:"email",fieldError:s(l).errors.get("email"),inputType:"email",label:"auth.forms.email",maxLength:255,autofocus:""},null,8,["modelValue","fieldError"]),a(f,{modelValue:s(l).password,"onUpdate:modelValue":e[2]||(e[2]=o=>s(l).password=o),fieldName:"password",fieldError:s(l).errors.get("password"),inputType:"password",label:"auth.forms.current_password.label",help:"auth.forms.current_password.help"},null,8,["modelValue","fieldError"]),a(h,{isBusy:s(l).isBusy,caption:"commons.update"},null,8,["isBusy"])],8,I)],32),n("form",{onSubmit:b(P,["prevent"]),onKeydown:e[7]||(e[7]=o=>s(t).onKeydown(o))},[n("h4",q,u(r.$t("settings.change_password")),1),n("fieldset",{disabled:s(c).config.proxyAuth||s(d).oauth_provider},[a(B,{modelValue:s(t).password,"onUpdate:modelValue":e[4]||(e[4]=o=>s(t).password=o),fieldName:"password",fieldError:s(t).errors.get("password"),autocomplete:"new-password",showRules:!0,label:"auth.forms.new_password"},null,8,["modelValue","fieldError"]),a(B,{modelValue:s(t).password_confirmation,"onUpdate:modelValue":e[5]||(e[5]=o=>s(t).password_confirmation=o),showRules:!1,fieldName:"password_confirmation",fieldError:s(t).errors.get("password_confirmation"),inputType:"password",autocomplete:"new-password",label:"auth.forms.confirm_new_password"},null,8,["modelValue","fieldError"]),a(f,{modelValue:s(t).currentPassword,"onUpdate:modelValue":e[6]||(e[6]=o=>s(t).currentPassword=o),fieldName:"currentPassword",fieldError:s(t).errors.get("currentPassword"),inputType:"password",label:"auth.forms.current_password.label",help:"auth.forms.current_password.help"},null,8,["modelValue","fieldError"]),a(h,{isBusy:s(t).isBusy,caption:"auth.forms.change_password"},null,8,["isBusy"])],8,G)],32),n("form",{id:"frmDeleteAccount",onSubmit:b($,["prevent"]),onKeydown:e[9]||(e[9]=o=>s(m).onKeydown(o))},[n("h4",J,u(r.$t("auth.forms.delete_account")),1),n("div",O,[n("p",Q,u(r.$t("auth.forms.delete_your_account_and_reset_all_data")),1),n("p",null,u(r.$t("auth.forms.reset_your_password_to_delete_your_account")),1),n("p",null,u(r.$t("auth.forms.deleting_2fauth_account_does_not_impact_provider")),1)]),n("fieldset",{disabled:s(c).config.proxyAuth},[a(f,{modelValue:s(m).password,"onUpdate:modelValue":e[8]||(e[8]=o=>s(m).password=o),fieldName:"password",fieldError:s(m).errors.get("password"),inputType:"password",autocomplete:"new-password",label:"auth.forms.current_password.label",help:"auth.forms.current_password.help"},null,8,["modelValue","fieldError"]),a(h,{isBusy:s(m).isBusy,caption:"auth.forms.delete_your_account",submitId:"btnDeleteAccount",color:"is-danger"},null,8,["isBusy"])],8,X)],32)]),_:1})]),a(A,{showButtons:!0},{default:E(()=>[a(k,{returnTo:{name:s(x)},action:"close"},null,8,["returnTo"])]),_:1})])}}};export{oe as default};