import{j as S,x as E,s as l,f as c,i as _,b as t,H as v,C as p,v as x,e as k,G as T,J as N,T as P,A as $,r as f,_ as A}from"./index-DLUb5LSe.js";import{u as B}from"./data-D7xXWmPy.js";import{_ as U}from"./TopBar.vue_vue_type_script_setup_true_lang-DNeo4_WD.js";const j={class:"pb-24 min-h-dvh"},z={class:"max-w-md mx-auto px-4 pt-2"},M={class:"space-y-3"},Y={class:"block"},G={class:"block"},H={class:"block"},I={key:0,class:"text-red-600 text-meta mt-3"},J={key:1,class:"text-emerald-700 text-meta mt-3"},K=["disabled"],R={class:"mt-10 rounded-card border border-red-200 bg-red-50/50 p-4"},q={class:"w-full bg-surface rounded-t-card p-6 safe-bottom max-w-md mx-auto"},F={class:"mt-5 flex gap-3"},L=["disabled"],O=S({__name:"ProfileEditView",setup(Q){var y,w,h;const C=$(),a=E(),g=B(),n=l(((y=a.me)==null?void 0:y.name)??""),d=l(((w=a.me)==null?void 0:w.phone)??""),i=l(((h=a.me)==null?void 0:h.email)??""),o=l(!1),u=l(""),r=l(!1),m=l(!1);async function D(){o.value=!0,u.value="",r.value=!1;const b=await g.updateProfile({name:n.value,phone:d.value||null,email:i.value||null});o.value=!1,b.ok?(a.me&&(a.me={...a.me,name:n.value,phone:d.value,email:i.value}),r.value=!0,setTimeout(()=>{r.value=!1},1800)):u.value=b.message??"Could not save."}async function V(){o.value=!0,await g.deleteAccount(),await a.logout(),C.replace("/login")}return(b,e)=>(f(),c("div",j,[_(U),t("main",z,[e[11]||(e[11]=t("h1",{class:"text-display py-4"},"Edit profile",-1)),t("div",M,[t("label",Y,[e[6]||(e[6]=t("span",{class:"text-meta font-semibold text-ink-muted"},"Name",-1)),v(t("input",{"onUpdate:modelValue":e[0]||(e[0]=s=>n.value=s),class:"mt-1 w-full h-12 px-4 rounded-card bg-surface border border-ink/10 focus:border-brand-500 focus:outline-none"},null,512),[[p,n.value]])]),t("label",G,[e[7]||(e[7]=t("span",{class:"text-meta font-semibold text-ink-muted"},"Phone",-1)),v(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>d.value=s),type:"tel",class:"mt-1 w-full h-12 px-4 rounded-card bg-surface border border-ink/10 focus:border-brand-500 focus:outline-none"},null,512),[[p,d.value]])]),t("label",H,[e[8]||(e[8]=t("span",{class:"text-meta font-semibold text-ink-muted"},"Email",-1)),v(t("input",{"onUpdate:modelValue":e[2]||(e[2]=s=>i.value=s),type:"email",class:"mt-1 w-full h-12 px-4 rounded-card bg-surface border border-ink/10 focus:border-brand-500 focus:outline-none"},null,512),[[p,i.value]])])]),u.value?(f(),c("p",I,x(u.value),1)):k("",!0),r.value?(f(),c("p",J,"✓ Saved")):k("",!0),t("button",{type:"button",disabled:o.value,class:"w-full mt-5 h-12 rounded-card bg-brand-500 text-white font-bold shadow-fab active:scale-[0.98] disabled:opacity-50",onClick:D},x(o.value?"Saving…":"Save changes"),9,K),t("div",R,[e[9]||(e[9]=t("div",{class:"text-meta font-bold text-red-800"},"Danger zone",-1)),e[10]||(e[10]=t("p",{class:"text-meta text-red-700/80 mt-1"},"Deactivate your account. Clinical records stay with the clinic for legal retention; we just sign you out everywhere and stop sending notifications.",-1)),t("button",{type:"button",class:"mt-3 px-4 h-10 rounded-pill bg-red-600 text-white text-meta font-bold",onClick:e[3]||(e[3]=s=>m.value=!0)}," Deactivate account ")])]),_(P,{name:"sheet"},{default:T(()=>[m.value?(f(),c("div",{key:0,class:"fixed inset-0 z-50 bg-black/40 flex items-end",onClick:e[5]||(e[5]=N(s=>m.value=!1,["self"]))},[t("div",q,[e[12]||(e[12]=t("div",{class:"text-display"},"Sure?",-1)),e[13]||(e[13]=t("p",{class:"text-meta text-ink-muted mt-2"},"This signs you out on every device and disables notifications. You can sign back up by contacting the clinic.",-1)),t("div",F,[t("button",{class:"flex-1 h-12 rounded-card bg-surface-muted text-ink font-semibold",onClick:e[4]||(e[4]=s=>m.value=!1)},"Keep my account"),t("button",{class:"flex-1 h-12 rounded-card bg-red-600 text-white font-bold",disabled:o.value,onClick:V},x(o.value?"…":"Yes, deactivate"),9,L)])])])):k("",!0)]),_:1})]))}}),ee=A(O,[["__scopeId","data-v-01423e87"]]);export{ee as default};
//# sourceMappingURL=ProfileEditView-BQP5SVXs.js.map
