import{_ as S,u as V,A as M,m as N,s as E,f as h,i as g,I as q,r,o as n,b as s,t as u,d as y,c as d,h as B,w as T,e as w,v as b,g as C,z as D,J as L,p as U}from"./index-BxvCedNV.js";import{C as I}from"./ClientLayout-dF5nUyG1.js";import{E as $}from"./ErrorMessage-CxvCfJLd.js";import{M as j}from"./ModalDialog-CcU1pcTN.js";const F={class:"client-home"},G={class:"card card--tight profile-card"},z={class:"profile-avatar"},J={class:"profile-info"},R={class:"profile-name"},W={class:"profile-email"},Y={class:"card card--tight push-card"},H={key:0,class:"push-card__status push-card__status--ok"},K={key:1,class:"push-card__status push-card__status--warn"},O={key:2,class:"push-card__status push-card__status--warn"},Q={key:3,class:"push-card__status"},X=["disabled"],Z={class:"card card--tight"},ss={class:"input-group"},as={class:"input-group"},es={class:"input-group"},ts={key:1,class:"perfil-pw-success"},os={class:"perfil-pw-actions"},ns=["disabled"],rs={__name:"PerfilView",setup(is){const v=V(),{requestPermissionAndSubscribe:k}=M(),o=r("default"),c=r(!1),i=r(!1),p=r(!1),l=r(""),_=r(!1),e=U({current_password:"",new_password:"",confirm_password:""});function f(){o.value=q()}N(()=>{f()}),E(f);const P=D(()=>(v.user?.name||"").split(" ").map(a=>a[0]).join("").substring(0,2).toUpperCase()||"CL");async function A(){c.value=!0;try{await k(),f()}finally{c.value=!1}}const x=async()=>{if(l.value="",_.value=!1,e.new_password!==e.confirm_password){l.value="Las contraseñas no coinciden";return}p.value=!0;try{await L.changePassword(e.current_password,e.new_password),_.value=!0,setTimeout(()=>{i.value=!1,e.current_password="",e.new_password="",e.confirm_password="",_.value=!1},1500)}catch(m){l.value=m.response?.data?.message||"Error al cambiar contraseña"}finally{p.value=!1}};return(m,a)=>(n(),h(I,null,{default:g(()=>[s("div",F,[a[12]||(a[12]=s("header",{class:"exp-head"},[s("p",{class:"exp-head__eyebrow"},"Tu cuenta"),s("h1",{class:"exp-head__title"},"Perfil"),s("p",{class:"exp-head__lead"},"Datos de acceso y avisos en este dispositivo.")],-1)),s("div",G,[s("div",z,u(P.value),1),s("div",J,[s("p",R,u(y(v).user?.name),1),s("p",W,u(y(v).user?.email),1)])]),s("div",Y,[a[6]||(a[6]=s("h3",{class:"title-sm push-card__title"},"Notificaciones",-1)),a[7]||(a[7]=s("p",{class:"push-card__desc"}," Recibí avisos cuando confirmen una cita, la cancelen o haya un cambio. Funciona mejor con la app instalada (PWA). ",-1)),o.value==="granted"?(n(),d("p",H," Avisos activados en este dispositivo. ")):o.value==="denied"?(n(),d("p",K," Están bloqueadas en el navegador. Abrí el candado o la configuración del sitio y permití notificaciones para esta página. ")):o.value==="unsupported"?(n(),d("p",O," Tu navegador no permite notificaciones push en esta vista. ")):(n(),d("p",Q,"Tocá el botón para permitir avisos cuando te lo pida el sistema.")),s("button",{type:"button",class:"btn btn-gold push-card__btn",disabled:c.value||o.value==="granted"||o.value==="unsupported",onClick:A},u(c.value?"Activando…":o.value==="granted"?"Ya activadas":"Activar avisos de citas"),9,X)]),s("div",Z,[a[8]||(a[8]=s("h3",{class:"exp-section-title"},"Acciones",-1)),s("button",{onClick:a[0]||(a[0]=t=>i.value=!0),class:"btn btn-outline"}," Cambiar contraseña ")]),B(j,{show:i.value,sheet:"",title:"Cambiar contraseña","show-actions":!1,onClose:a[5]||(a[5]=t=>i.value=!1)},{default:g(()=>[s("form",{class:"perfil-pw-form",onSubmit:T(x,["prevent"])},[s("div",ss,[a[9]||(a[9]=s("label",null,"Contraseña actual",-1)),w(s("input",{"onUpdate:modelValue":a[1]||(a[1]=t=>e.current_password=t),type:"password",class:"input-control",required:""},null,512),[[b,e.current_password]])]),s("div",as,[a[10]||(a[10]=s("label",null,"Nueva contraseña",-1)),w(s("input",{"onUpdate:modelValue":a[2]||(a[2]=t=>e.new_password=t),type:"password",class:"input-control",required:"",minlength:"6"},null,512),[[b,e.new_password]])]),s("div",es,[a[11]||(a[11]=s("label",null,"Confirmar nueva",-1)),w(s("input",{"onUpdate:modelValue":a[3]||(a[3]=t=>e.confirm_password=t),type:"password",class:"input-control",required:""},null,512),[[b,e.confirm_password]])]),l.value?(n(),h($,{key:0,message:l.value},null,8,["message"])):C("",!0),_.value?(n(),d("p",ts,"Contraseña cambiada correctamente.")):C("",!0),s("div",os,[s("button",{type:"button",class:"btn btn-outline",onClick:a[4]||(a[4]=t=>i.value=!1)},"Cancelar"),s("button",{type:"submit",class:"btn btn-gold",disabled:p.value},u(p.value?"Guardando…":"Guardar"),9,ns)])],32)]),_:1},8,["show"])])]),_:1}))}},ps=S(rs,[["__scopeId","data-v-c6cb34ee"]]);export{ps as default};
