import{_ as V,u as x,B as M,m as N,q,f as g,i as h,I as B,r,o as n,b as a,t as u,d as y,c as d,h as E,w as T,e as w,v as b,g as C,A as L,J as U,p as D}from"./index-BvB8QyFV.js";import{C as I}from"./ClientLayout-C6SftfaO.js";import{E as $}from"./ErrorMessage-v-UNPzPo.js";import{M as j}from"./ModalDialog-ocLhr0tO.js";const F={class:"card profile-card"},G={class:"profile-avatar"},z={class:"profile-info"},J={class:"profile-name"},R={class:"profile-email"},W={class:"card push-card"},Y={key:0,class:"push-card__status push-card__status--ok"},H={key:1,class:"push-card__status push-card__status--warn"},K={key:2,class:"push-card__status push-card__status--warn"},O={key:3,class:"push-card__status"},Q=["disabled"],X={class:"card"},Z={class:"input-group"},ss={class:"input-group"},as={class:"input-group"},es={key:1,class:"perfil-pw-success"},ts={class:"perfil-pw-actions"},os=["disabled"],ns={__name:"PerfilView",setup(rs){const m=x(),{requestPermissionAndSubscribe:k}=M(),o=r("default"),p=r(!1),i=r(!1),c=r(!1),l=r(""),v=r(!1),e=D({current_password:"",new_password:"",confirm_password:""});function f(){o.value=B()}N(()=>{f()}),q(f);const P=L(()=>(m.user?.name||"").split(" ").map(s=>s[0]).join("").substring(0,2).toUpperCase()||"CL");async function A(){p.value=!0;try{await k(),f()}finally{p.value=!1}}const S=async()=>{if(l.value="",v.value=!1,e.new_password!==e.confirm_password){l.value="Las contraseñas no coinciden";return}c.value=!0;try{await U.changePassword(e.current_password,e.new_password),v.value=!0,setTimeout(()=>{i.value=!1,e.current_password="",e.new_password="",e.confirm_password="",v.value=!1},1500)}catch(_){l.value=_.response?.data?.message||"Error al cambiar contraseña"}finally{c.value=!1}};return(_,s)=>(n(),g(I,null,{default:h(()=>[s[12]||(s[12]=a("h2",{style:{margin:"0 0 5px 0","font-size":"22px"}},"Perfil",-1)),s[13]||(s[13]=a("p",{class:"title-sm",style:{"margin-top":"0"}},"Tu información",-1)),a("div",F,[a("div",G,u(P.value),1),a("div",z,[a("p",J,u(y(m).user?.name),1),a("p",R,u(y(m).user?.email),1)])]),a("div",W,[s[6]||(s[6]=a("h3",{class:"title-sm push-card__title"},"Notificaciones",-1)),s[7]||(s[7]=a("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",Y," Avisos activados en este dispositivo. ")):o.value==="denied"?(n(),d("p",H," 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",K," Tu navegador no permite notificaciones push en esta vista. ")):(n(),d("p",O,"Tocá el botón para permitir avisos cuando te lo pida el sistema.")),a("button",{type:"button",class:"btn btn-gold push-card__btn",disabled:p.value||o.value==="granted"||o.value==="unsupported",onClick:A},u(p.value?"Activando…":o.value==="granted"?"Ya activadas":"Activar avisos de citas"),9,Q)]),a("div",X,[s[8]||(s[8]=a("h3",{class:"title-sm",style:{"margin-top":"0"}},"Acciones",-1)),a("button",{onClick:s[0]||(s[0]=t=>i.value=!0),class:"btn btn-outline"}," Cambiar contraseña ")]),E(j,{show:i.value,sheet:"",title:"Cambiar contraseña","show-actions":!1,onClose:s[5]||(s[5]=t=>i.value=!1)},{default:h(()=>[a("form",{class:"perfil-pw-form",onSubmit:T(S,["prevent"])},[a("div",Z,[s[9]||(s[9]=a("label",null,"Contraseña actual",-1)),w(a("input",{"onUpdate:modelValue":s[1]||(s[1]=t=>e.current_password=t),type:"password",class:"input-control",required:""},null,512),[[b,e.current_password]])]),a("div",ss,[s[10]||(s[10]=a("label",null,"Nueva contraseña",-1)),w(a("input",{"onUpdate:modelValue":s[2]||(s[2]=t=>e.new_password=t),type:"password",class:"input-control",required:"",minlength:"6"},null,512),[[b,e.new_password]])]),a("div",as,[s[11]||(s[11]=a("label",null,"Confirmar nueva",-1)),w(a("input",{"onUpdate:modelValue":s[3]||(s[3]=t=>e.confirm_password=t),type:"password",class:"input-control",required:""},null,512),[[b,e.confirm_password]])]),l.value?(n(),g($,{key:0,message:l.value},null,8,["message"])):C("",!0),v.value?(n(),d("p",es,"Contraseña cambiada correctamente.")):C("",!0),a("div",ts,[a("button",{type:"button",class:"btn btn-outline",onClick:s[4]||(s[4]=t=>i.value=!1)},"Cancelar"),a("button",{type:"submit",class:"btn btn-gold",disabled:c.value},u(c.value?"Guardando…":"Guardar"),9,os)])],32)]),_:1},8,["show"])]),_:1}))}},ps=V(ns,[["__scopeId","data-v-1f4fa320"]]);export{ps as default};
