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,v as d,vt as f,y as p,z as m,zt as h}from"./vue.runtime.esm-bundler-DAWRyTnP.js";import{i as g}from"./vue-router-Bna4o8ws.js";import{n as _}from"./vue-i18n-C4HYJWrq.js";import{$ as v,J as y,K as b,Mn as x,W as S,Z as C}from"./main-CgSmSYZA.js";import{n as w,t as T}from"./global-baPAcFzD.js";var E={class:`font-bold text-left`},D={class:`mt-2 text-sm leading-snug text-left text-gray-500`,style:{"max-width":`680px`}},O={class:`grid gap-6 sm:grid-col-1 md:grid-cols-2 mt-6`},k={__name:`CustomerSettings`,setup(k){let A=w();T(),g();let{t:j,tm:M}=_(),N=o([]),P=o(!1),F=o(null),I=o(!1),L=o(!1),R=o(!1);A.userForm.avatar&&N.value.push({image:A.userForm.avatar});let z=x(c(()=>({userForm:{name:{required:S.withMessage(j(`validation.required`),C),minLength:S.withMessage(j(`validation.name_min_length`,{count:3}),y(3))},email:{required:S.withMessage(j(`validation.required`),C),email:S.withMessage(j(`validation.email_incorrect`),b)},password:{minLength:S.withMessage(j(`validation.password_min_length`,{count:8}),y(8))},confirm_password:{sameAsPassword:S.withMessage(j(`validation.password_incorrect`),v(A.userForm.password))}}})),c(()=>A));function B(e,t){F.value=t}function V(){F.value=null,R.value=!0}function H(){if(z.value.userForm.$touch(),z.value.userForm.$invalid)return!0;P.value=!0;let e=new FormData;e.append(`name`,A.userForm.name),e.append(`email`,A.userForm.email),A.userForm.password!=null&&A.userForm.password!==void 0&&A.userForm.password!==``&&e.append(`password`,A.userForm.password),F.value&&e.append(`customer_avatar`,F.value),e.append(`is_customer_avatar_removed`,R.value),A.updateCurrentUser({data:e,message:M(`settings.account_settings.updated_message`)}).then(e=>{e.data.data&&(P.value=!1,A.$patch(e=>{e.userForm.password=``,e.userForm.confirm_password=``}),F.value=null,R.value=!1)}).catch(e=>{P.value=!1})}return(o,c)=>{let g=n(`BaseFileUploader`),_=n(`BaseInputGroup`),v=n(`BaseInput`),y=n(`BaseIcon`),b=n(`BaseButton`),x=n(`BaseCard`);return m(),p(`form`,{class:`relative h-full mt-4`,onSubmit:u(H,[`prevent`])},[t(x,null,{default:e(()=>[s(`div`,null,[s(`h6`,E,i(o.$t(`settings.account_settings.account_settings`)),1),s(`p`,D,i(o.$t(`settings.account_settings.section_description`)),1)]),s(`div`,O,[t(_,{label:o.$t(`settings.account_settings.profile_picture`)},{default:e(()=>[t(g,{modelValue:f(N),"onUpdate:modelValue":c[0]||=e=>l(N)?N.value=e:N=e,avatar:!0,accept:`image/*`,onChange:B,onRemove:V},null,8,[`modelValue`])]),_:1},8,[`label`]),c[11]||=s(`span`,null,null,-1),t(_,{label:o.$t(`settings.account_settings.name`),error:f(z).userForm.name.$error&&f(z).userForm.name.$errors[0].$message,required:``},{default:e(()=>[t(v,{modelValue:f(A).userForm.name,"onUpdate:modelValue":c[1]||=e=>f(A).userForm.name=e,invalid:f(z).userForm.name.$error,onInput:c[2]||=e=>f(z).userForm.name.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`label`,`error`]),t(_,{label:o.$t(`settings.account_settings.email`),error:f(z).userForm.email.$error&&f(z).userForm.email.$errors[0].$message,required:``},{default:e(()=>[t(v,{modelValue:f(A).userForm.email,"onUpdate:modelValue":c[3]||=e=>f(A).userForm.email=e,invalid:f(z).userForm.email.$error,onInput:c[4]||=e=>f(z).userForm.email.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`label`,`error`]),t(_,{error:f(z).userForm.password.$error&&f(z).userForm.password.$errors[0].$message,label:o.$t(`settings.account_settings.password`)},{default:e(()=>[t(v,{modelValue:f(A).userForm.password,"onUpdate:modelValue":c[6]||=e=>f(A).userForm.password=e,type:f(I)?`text`:`password`,invalid:f(z).userForm.password.$error,onInput:c[7]||=e=>f(z).userForm.password.$touch()},{right:e(()=>[t(y,{name:f(I)?`EyeIcon`:`EyeSlashIcon`,class:`mr-1 text-gray-500 cursor-pointer`,onClick:c[5]||=e=>l(I)?I.value=!f(I):I=!f(I)},null,8,[`name`])]),_:1},8,[`modelValue`,`type`,`invalid`])]),_:1},8,[`error`,`label`]),t(_,{label:o.$t(`settings.account_settings.confirm_password`),error:f(z).userForm.confirm_password.$error&&f(z).userForm.confirm_password.$errors[0].$message},{default:e(()=>[t(v,{modelValue:f(A).userForm.confirm_password,"onUpdate:modelValue":c[9]||=e=>f(A).userForm.confirm_password=e,type:f(L)?`text`:`password`,invalid:f(z).userForm.confirm_password.$error,onInput:c[10]||=e=>f(z).userForm.confirm_password.$touch()},{right:e(()=>[t(y,{name:f(L)?`EyeIcon`:`EyeSlashIcon`,class:`mr-1 text-gray-500 cursor-pointer`,onClick:c[8]||=e=>l(L)?L.value=!f(L):L=!f(L)},null,8,[`name`])]),_:1},8,[`modelValue`,`type`,`invalid`])]),_:1},8,[`label`,`error`])]),t(b,{loading:f(P),disabled:f(P),class:`mt-6`},{left:e(e=>[f(P)?d(``,!0):(m(),a(y,{key:0,name:`ArrowDownOnSquareIcon`,class:h(e.class)},null,8,[`class`]))]),default:e(()=>[r(` `+i(o.$t(`general.save`)),1)]),_:1},8,[`loading`,`disabled`])]),_:1})],32)}}};export{k as default};