import{_ as C,u as k,f as c,i as x,o as n,b as a,t as d,d as b,T as B,c as _,w as V,e as v,v as f,g as w,y as P,r as u,D as E,p as S}from"./index-BfaD9LDQ.js";import{B as T}from"./BarberLayout-D_0exqc6.js";import{E as A}from"./ErrorMessage-XnajRwz6.js";import"./LogoutButton-D6CsMTMd.js";const M={class:"card profile-card"},N={class:"profile-avatar"},U={class:"profile-info"},h={class:"profile-name"},q={class:"profile-email"},D={class:"card"},L={key:0,class:"modal-overlay"},$={class:"modal-card"},I={class:"input-group"},j={class:"input-group"},z={class:"input-group"},F={key:1,class:"success-text"},R={class:"modal-actions"},G=["disabled"],H={__name:"BarberPerfilView",setup(J){const p=k(),o=u(!1),l=u(!1),r=u(""),i=u(!1),e=S({current_password:"",new_password:"",confirm_password:""}),y=P(()=>(p.user?.name||"").split(" ").map(s=>s[0]).join("").substring(0,2).toUpperCase()||"BR"),g=async()=>{if(r.value="",i.value=!1,e.new_password!==e.confirm_password){r.value="Las contraseñas no coinciden";return}l.value=!0;try{await E.changePassword(e.current_password,e.new_password),i.value=!0,setTimeout(()=>{o.value=!1,e.current_password="",e.new_password="",e.confirm_password="",i.value=!1},1500)}catch(m){r.value=m.response?.data?.message||"Error al cambiar contraseña"}finally{l.value=!1}};return(m,s)=>(n(),c(T,null,{default:x(()=>[s[11]||(s[11]=a("h2",{style:{margin:"0 0 5px 0","font-size":"22px"}},"Perfil",-1)),s[12]||(s[12]=a("p",{class:"title-sm",style:{"margin-top":"0"}},"Tu información",-1)),a("div",M,[a("div",N,d(y.value),1),a("div",U,[a("p",h,d(b(p).user?.name),1),a("p",q,d(b(p).user?.email),1)])]),a("div",D,[s[6]||(s[6]=a("h3",{class:"title-sm",style:{"margin-top":"0"}},"Acciones",-1)),a("button",{onClick:s[0]||(s[0]=t=>o.value=!0),class:"btn btn-outline"}," Cambiar contraseña ")]),(n(),c(B,{to:"body"},[o.value?(n(),_("div",L,[a("div",{class:"modal-backdrop",onClick:s[1]||(s[1]=t=>o.value=!1)}),a("div",$,[s[10]||(s[10]=a("h3",{class:"modal-title"},"Cambiar Contraseña",-1)),a("form",{onSubmit:V(g,["prevent"])},[a("div",I,[s[7]||(s[7]=a("label",null,"Contraseña Actual",-1)),v(a("input",{"onUpdate:modelValue":s[2]||(s[2]=t=>e.current_password=t),type:"password",class:"input-control",required:""},null,512),[[f,e.current_password]])]),a("div",j,[s[8]||(s[8]=a("label",null,"Nueva Contraseña",-1)),v(a("input",{"onUpdate:modelValue":s[3]||(s[3]=t=>e.new_password=t),type:"password",class:"input-control",required:"",minlength:"6"},null,512),[[f,e.new_password]])]),a("div",z,[s[9]||(s[9]=a("label",null,"Confirmar Nueva",-1)),v(a("input",{"onUpdate:modelValue":s[4]||(s[4]=t=>e.confirm_password=t),type:"password",class:"input-control",required:""},null,512),[[f,e.confirm_password]])]),r.value?(n(),c(A,{key:0,message:r.value},null,8,["message"])):w("",!0),i.value?(n(),_("p",F,"Contraseña cambiada exitosamente")):w("",!0),a("div",R,[a("button",{type:"button",onClick:s[5]||(s[5]=t=>o.value=!1),class:"btn btn-outline btn-sm"},"Cancelar"),a("button",{type:"submit",disabled:l.value,class:"btn btn-gold btn-sm"},d(l.value?"Cambiando...":"Cambiar"),9,G)])],32)])])):w("",!0)]))]),_:1}))}},X=C(H,[["__scopeId","data-v-d9529e71"]]);export{X as default};
