import{$ as e,C as t,G as n,S as r,Wt as i,_ as a,dt as o,g as s,h as c,st as l,u,ut as d,v as f,vt as p,y as m,z as h,zt as g}from"./vue.runtime.esm-bundler-DAWRyTnP.js";import{t as _}from"./user-gWi04hVo.js";import{t as v}from"./company-BhXg3qcB.js";import{t as y}from"./global-BGJPTjg4.js";import{n as b}from"./vue-i18n-C4HYJWrq.js";import{$ as x,J as S,K as C,Mn as w,W as T,Z as E}from"./main-CVDkKXbu.js";var D={__name:`AccountSetting`,setup(D){let O=_(),k=y(),A=v(),{t:j}=b(),M=o(!1),N=o(null),P=o([]),F=o(!1);O.currentUser.avatar&&P.value.push({image:O.currentUser.avatar});let I=c(()=>({name:{required:T.withMessage(j(`validation.required`),E)},email:{required:T.withMessage(j(`validation.required`),E),email:T.withMessage(j(`validation.email_incorrect`),C)},password:{minLength:T.withMessage(j(`validation.password_length`,{count:8}),S(8))},confirm_password:{sameAsPassword:T.withMessage(j(`validation.password_incorrect`),x(L.password))}})),L=d({name:O.currentUser.name,email:O.currentUser.email,language:O.currentUserSettings.language||A.selectedCompanySettings.language,password:``,confirm_password:``}),R=w(I,c(()=>L));function z(e,t){N.value=t}function B(){N.value=null,F.value=!0}async function V(){if(R.value.$touch(),R.value.$invalid)return!0;M.value=!0;let e={name:L.name,email:L.email};try{if(L.password!=null&&L.password!==void 0&&L.password!==``&&(e={...e,password:L.password}),O.currentUserSettings.language!==L.language&&(await window.loadLanguage(L.language),await O.updateUserSettings({settings:{language:L.language}})),(await O.updateCurrentUser(e)).data.data){if(M.value=!1,N.value||F.value){let e=new FormData;N.value&&e.append(`admin_avatar`,N.value),e.append(`is_admin_avatar_removed`,F.value),await O.uploadAvatar(e),N.value=null,F.value=!1}L.password=``,L.confirm_password=``}}catch{return M.value=!1,!0}}return(o,c)=>{let d=n(`BaseFileUploader`),_=n(`BaseInputGroup`),v=n(`BaseInput`),y=n(`BaseMultiselect`),b=n(`BaseInputGrid`),x=n(`BaseIcon`),S=n(`BaseButton`),C=n(`BaseSettingCard`);return h(),m(`form`,{class:`relative`,onSubmit:u(V,[`prevent`])},[t(C,{title:o.$t(`settings.account_settings.account_settings`),description:o.$t(`settings.account_settings.section_description`)},{default:e(()=>[t(b,null,{default:e(()=>[t(_,{label:o.$t(`settings.account_settings.profile_picture`)},{default:e(()=>[t(d,{modelValue:p(P),"onUpdate:modelValue":c[0]||=e=>l(P)?P.value=e:P=e,avatar:!0,accept:`image/*`,onChange:z,onRemove:B},null,8,[`modelValue`])]),_:1},8,[`label`]),c[10]||=s(`span`,null,null,-1),t(_,{label:o.$t(`settings.account_settings.name`),error:p(R).name.$error&&p(R).name.$errors[0].$message,required:``},{default:e(()=>[t(v,{modelValue:L.name,"onUpdate:modelValue":c[1]||=e=>L.name=e,invalid:p(R).name.$error,onInput:c[2]||=e=>p(R).name.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`label`,`error`]),t(_,{label:o.$t(`settings.account_settings.email`),error:p(R).email.$error&&p(R).email.$errors[0].$message,required:``},{default:e(()=>[t(v,{modelValue:L.email,"onUpdate:modelValue":c[3]||=e=>L.email=e,invalid:p(R).email.$error,onInput:c[4]||=e=>p(R).email.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`label`,`error`]),t(_,{error:p(R).password.$error&&p(R).password.$errors[0].$message,label:o.$t(`settings.account_settings.password`)},{default:e(()=>[t(v,{modelValue:L.password,"onUpdate:modelValue":c[5]||=e=>L.password=e,type:`password`,onInput:c[6]||=e=>p(R).password.$touch()},null,8,[`modelValue`])]),_:1},8,[`error`,`label`]),t(_,{label:o.$t(`settings.account_settings.confirm_password`),error:p(R).confirm_password.$error&&p(R).confirm_password.$errors[0].$message},{default:e(()=>[t(v,{modelValue:L.confirm_password,"onUpdate:modelValue":c[7]||=e=>L.confirm_password=e,type:`password`,onInput:c[8]||=e=>p(R).confirm_password.$touch()},null,8,[`modelValue`])]),_:1},8,[`label`,`error`]),t(_,{label:o.$t(`settings.language`)},{default:e(()=>[t(y,{modelValue:L.language,"onUpdate:modelValue":c[9]||=e=>L.language=e,options:p(k).config.languages,label:`name`,"value-prop":`code`,"track-by":`name`,searchable:!0,"open-direction":`top`},null,8,[`modelValue`,`options`])]),_:1},8,[`label`])]),_:1}),t(S,{loading:p(M),disabled:p(M),class:`mt-6`},{left:e(e=>[p(M)?f(``,!0):(h(),a(x,{key:0,name:`ArrowDownOnSquareIcon`,class:g(e.class)},null,8,[`class`]))]),default:e(()=>[r(` `+i(o.$t(`settings.company_info.save`)),1)]),_:1},8,[`loading`,`disabled`])]),_:1},8,[`title`,`description`])],32)}}};export{D as default};