var O=Object.defineProperty,P=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var v=(a,t,r)=>t in a?O(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,k=(a,t)=>{for(var r in t||(t={}))R.call(t,r)&&v(a,r,t[r]);if(g)for(var r of g(t))J.call(t,r)&&v(a,r,t[r]);return a},y=(a,t)=>P(a,U(t));import{aT as M,r as c,aU as B,j as e,dF as H}from"./react-vendor-xYZnmIII.js";import{I as T}from"./input-error-_LAmvivg.js";import{L as $}from"./loading-button-D7aXR3K4.js";import{L as p,I as u}from"./ui-components-CQM92IK3.js";import{o as w}from"./inertia-FIn3q7f1.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const Z=()=>{const{auth:a,errors:t,translate:r}=M().props,{button:x,input:l,common:q}=r,h=a.user,[N,C]=c.useState(h.photo),[d,j]=c.useState({website:"",facebook:"",twitter:"",linkedin:""}),_=c.useCallback(s=>{try{if(!s)return;const o=typeof s=="string"?JSON.parse(s):s,n={website:"",facebook:"",twitter:"",linkedin:""};o.forEach(i=>{i.host in n&&(n[i.host]=i.profile_link)}),j(n)}catch(o){}},[]);c.useEffect(()=>{_(h.social_links)},[h.social_links]);const b=c.useCallback(s=>{const o=Object.entries(s).filter(([n,i])=>i).map(([n,i])=>({host:n,profile_link:i}));return JSON.stringify(o)},[]),m=c.useCallback((s,o)=>{j(n=>y(k({},n),{[s]:o}))},[]),{data:S,post:L,setData:f,processing:E}=B({name:h.name||"",photo:null,social_links:null});c.useEffect(()=>{f("social_links",b(d))},[d,b,f]);const F=s=>{s.preventDefault(),L(route("student.profile.update"))},I=(s,o)=>{f(s,o),C(URL.createObjectURL(o))};return e.jsxs("form",{onSubmit:F,className:"bg-card grid grid-cols-1 gap-6 rounded-lg p-6 md:grid-cols-2",children:[e.jsxs("div",{className:"col-span-full space-y-1",children:[e.jsx("div",{className:"border-border h-[150px] w-[150px] rounded-full border border-dashed p-1.5",children:e.jsxs("div",{className:"border-border relative h-full w-full overflow-hidden rounded-full border",children:[e.jsx("img",{alt:`${a.user.name}'s profile`,src:N||"/assets/icons/avatar.png",className:"h-full w-full content-center object-cover"}),e.jsxs("label",{htmlFor:"formFile",className:"text-primary-foreground absolute right-0 bottom-0 flex h-full w-full cursor-pointer flex-col items-center justify-center gap-2 bg-black/50 opacity-0 transition-opacity duration-300 hover:opacity-100",children:[e.jsx(H,{className:"h-7 w-7"}),e.jsx("span",{className:"text-xs",children:x.upload})]}),e.jsx("input",{hidden:!0,type:"file",id:"formFile",name:"photo",onChange:s=>w(s,I)})]})}),t.photo&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:t.photo})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(p,{children:l.name}),e.jsx(u,{type:"text",name:"name",value:S.name,onChange:s=>w(s,f),placeholder:l.full_name_placeholder}),e.jsx(T,{message:t.name})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(p,{children:l.website}),e.jsx(u,{type:"url",name:"website",value:d.website,onChange:s=>m("website",s.target.value),placeholder:l.https_placeholder})]}),e.jsxs("div",{children:[e.jsx(p,{children:l.facebook}),e.jsx(u,{type:"url",value:d.facebook,onChange:s=>m("facebook",s.target.value),placeholder:l.https_placeholder})]}),e.jsxs("div",{children:[e.jsx(p,{children:l.twitter}),e.jsx(u,{type:"url",value:d.twitter,onChange:s=>m("twitter",s.target.value),placeholder:l.https_placeholder})]}),e.jsxs("div",{children:[e.jsx(p,{children:l.linkedin}),e.jsx(u,{type:"url",value:d.linkedin,onChange:s=>m("linkedin",s.target.value),placeholder:l.https_placeholder})]}),e.jsx("div",{className:"col-span-full flex items-center justify-end pt-2",children:e.jsx($,{loading:E,className:"col-span-full",children:x.update})})]})};export{Z as default};
