import{_ as b,a as f,b as m,d as s,t as C,p as g,q as n,v as i,n as P,r as F,c as U,o as V,k as u}from"./app-kAt5lVqd.js";const h={setup(){const e=P({name:"",email:"",phone:"",address:"",avatar:"",roles:[]}),o=P({current_password:"",password:"",password_confirmation:""}),w=F(null),r=U(()=>e.name?e.name.charAt(0).toUpperCase():"A"),v=async()=>{try{const{data:a}=await u.get("/admin/profile");a.success&&Object.assign(e,a.data)}catch{alert("Failed to load profile")}},c=async()=>{var a,l;try{const{data:t}=await u.put("/admin/profile",e);t.success&&alert("Profile updated successfully")}catch(t){alert(((l=(a=t.response)==null?void 0:a.data)==null?void 0:l.message)||"Failed to update profile")}},d=async a=>{const l=a.target.files[0];if(l)try{const t=new FormData;t.append("photo",l);const{data:y}=await u.post("/admin/profile/photo",t,{headers:{"Content-Type":"multipart/form-data"}});y.success&&(e.avatar=y.data.avatar,alert("Photo updated successfully"))}catch{alert("Failed to upload photo")}},p=async()=>{var a,l;try{const{data:t}=await u.post("/admin/profile/password",o);t.success&&(alert("Password updated successfully"),o.current_password="",o.password="",o.password_confirmation="")}catch(t){alert(((l=(a=t.response)==null?void 0:a.data)==null?void 0:l.message)||"Failed to update password")}};return V(()=>{v()}),{profile:e,passwordForm:o,fileInput:w,userInitial:r,updateProfile:c,handlePhotoChange:d,updatePassword:p}}},k={class:"profile-page"},q={class:"profile-content"},I={class:"photo-card"},x={class:"photo-section"},_={class:"avatar-large"},D=["src"],M={key:1},S={class:"info-card"},A={class:"form-group"},B={class:"form-group"},N={class:"form-group"},E={class:"form-group"},T={class:"form-group"},j=["value"],O={class:"info-card"},R={class:"form-group"},z={class:"form-group"},G={class:"form-group"};function H(e,o,w,r,v,c){var d,p;return m(),f("div",k,[o[23]||(o[23]=s("div",{class:"profile-header"},[s("h2",null,"👤 My Profile")],-1)),s("div",q,[s("div",I,[s("div",x,[s("div",_,[r.profile.avatar?(m(),f("img",{key:0,src:`/storage/${r.profile.avatar}`,alt:"Profile"},null,8,D)):(m(),f("span",M,C(r.userInitial),1))]),s("input",{ref:"fileInput",onChange:o[0]||(o[0]=(...a)=>r.handlePhotoChange&&r.handlePhotoChange(...a)),type:"file",accept:"image/*",style:{display:"none"}},null,544),s("button",{onClick:o[1]||(o[1]=a=>e.$refs.fileInput.click()),class:"btn-upload"},"📷 Change Photo")])]),s("div",S,[o[17]||(o[17]=s("h3",null,"Profile Information",-1)),s("form",{onSubmit:o[6]||(o[6]=g((...a)=>r.updateProfile&&r.updateProfile(...a),["prevent"])),class:"profile-form"},[s("div",A,[o[11]||(o[11]=s("label",null,"Name",-1)),n(s("input",{"onUpdate:modelValue":o[2]||(o[2]=a=>r.profile.name=a),type:"text",required:"",class:"form-input"},null,512),[[i,r.profile.name]])]),s("div",B,[o[12]||(o[12]=s("label",null,"Email",-1)),n(s("input",{"onUpdate:modelValue":o[3]||(o[3]=a=>r.profile.email=a),type:"email",required:"",class:"form-input"},null,512),[[i,r.profile.email]])]),s("div",N,[o[13]||(o[13]=s("label",null,"Phone",-1)),n(s("input",{"onUpdate:modelValue":o[4]||(o[4]=a=>r.profile.phone=a),type:"text",required:"",class:"form-input"},null,512),[[i,r.profile.phone]])]),s("div",E,[o[14]||(o[14]=s("label",null,"Address",-1)),n(s("textarea",{"onUpdate:modelValue":o[5]||(o[5]=a=>r.profile.address=a),rows:"3",class:"form-input"},null,512),[[i,r.profile.address]])]),s("div",T,[o[15]||(o[15]=s("label",null,"Role",-1)),s("input",{value:(p=(d=r.profile.roles)==null?void 0:d[0])==null?void 0:p.name,disabled:"",class:"form-input"},null,8,j)]),o[16]||(o[16]=s("button",{type:"submit",class:"btn-save"},"💾 Save Changes",-1))],32)]),s("div",O,[o[22]||(o[22]=s("h3",null,"Change Password",-1)),s("form",{onSubmit:o[10]||(o[10]=g((...a)=>r.updatePassword&&r.updatePassword(...a),["prevent"])),class:"profile-form"},[s("div",R,[o[18]||(o[18]=s("label",null,"Current Password",-1)),n(s("input",{"onUpdate:modelValue":o[7]||(o[7]=a=>r.passwordForm.current_password=a),type:"password",required:"",class:"form-input"},null,512),[[i,r.passwordForm.current_password]])]),s("div",z,[o[19]||(o[19]=s("label",null,"New Password",-1)),n(s("input",{"onUpdate:modelValue":o[8]||(o[8]=a=>r.passwordForm.password=a),type:"password",required:"",class:"form-input"},null,512),[[i,r.passwordForm.password]])]),s("div",G,[o[20]||(o[20]=s("label",null,"Confirm Password",-1)),n(s("input",{"onUpdate:modelValue":o[9]||(o[9]=a=>r.passwordForm.password_confirmation=a),type:"password",required:"",class:"form-input"},null,512),[[i,r.passwordForm.password_confirmation]])]),o[21]||(o[21]=s("button",{type:"submit",class:"btn-save"},"🔒 Update Password",-1))],32)])])])}const K=b(h,[["render",H],["__scopeId","data-v-fd5b0a3a"]]);export{K as default};
