diff --git a/client/dist/assets/index-fGieArf4.js b/client/dist/assets/index-q7Zr2PlQ.js similarity index 90% rename from client/dist/assets/index-fGieArf4.js rename to client/dist/assets/index-q7Zr2PlQ.js index f5417474..374c9ec2 100644 --- a/client/dist/assets/index-fGieArf4.js +++ b/client/dist/assets/index-q7Zr2PlQ.js @@ -472,7 +472,7 @@ Error generating stack: `+i.message+` font-size: 0.8rem; /* Smaller font size */ } } - `}),u.jsxs(et,{sx:{maxWidth:"100%",mx:"auto",my:2,display:"flex",flexDirection:"column",height:"91vh",borderRadius:2,boxShadow:1},children:[u.jsxs(id,{sx:{display:"flex",flexDirection:"column",height:"100%",borderRadius:2,boxShadow:3},children:[u.jsxs(Cm,{sx:{flexGrow:1,overflow:"auto",padding:3,position:"relative"},children:[u.jsxs(et,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",position:"relative",marginBottom:"5px"},children:[u.jsx(Ln,{title:"Toggle voice responses",children:u.jsx(lt,{color:"inherit",onClick:ee,sx:{padding:0},children:u.jsx(d2,{checked:t,onChange:j=>n(j.target.checked),icon:u.jsx(Cs,{}),checkedIcon:u.jsx(Ss,{}),inputProps:{"aria-label":"Voice response toggle"},color:"default",sx:{height:42,"& .MuiSwitch-switchBase":{padding:"9px"},"& .MuiSwitch-switchBase.Mui-checked":{color:"white",transform:"translateX(16px)","& + .MuiSwitch-track":{backgroundColor:"primary.main"}}}})})}),u.jsx(Ln,{title:"Start a new chat",placement:"top",arrow:!0,children:u.jsx(lt,{"aria-label":"new chat",color:"primary",onClick:B,disabled:g,sx:{"&:hover":{backgroundColor:"primary.main",color:"common.white"}},children:u.jsx(Um,{})})})]}),u.jsx(Wi,{sx:{marginBottom:"10px"}}),b.length===0&&u.jsxs(et,{sx:{display:"flex",marginBottom:2,marginTop:3},children:[u.jsx(Er,{src:Pi,sx:{width:44,height:44,marginRight:2},alt:"Aria"}),u.jsx(Ie,{variant:"h4",component:"h1",gutterBottom:!0,children:"Welcome to Mental Health Companion"})]}),R?u.jsx(AN,{}):d.length===0&&u.jsxs(et,{sx:{display:"flex"},children:[u.jsx(Er,{src:Pi,sx:{width:36,height:36,marginRight:1},alt:"Aria"}),u.jsxs(Ie,{variant:"body1",gutterBottom:!0,sx:{bgcolor:"grey.200",borderRadius:"16px",px:2,py:1,display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"nowrap"},children:[b,t&&b&&u.jsx(lt,{onClick:()=>J(b),size:"small",sx:{ml:1},children:H(b)})]})]}),u.jsx(Ws,{sx:{maxHeight:"100%",overflow:"auto"},children:d.map((j,A)=>u.jsx(_c,{sx:{display:"flex",flexDirection:"column",alignItems:j.sender==="user"?"flex-end":"flex-start",borderRadius:2,mb:.5,p:1,border:"none","&:before":{display:"none"},"&:after":{display:"none"}},children:u.jsxs(et,{sx:{display:"flex",alignItems:"center",color:j.sender==="user"?"common.white":"text.primary",borderRadius:"16px"},children:[j.sender==="agent"&&u.jsx(Er,{src:Pi,sx:{width:36,height:36,mr:1},alt:"Aria"}),u.jsx(ws,{primary:u.jsxs(et,{sx:{display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"nowrap"},children:[j.message,t&&j.sender==="agent"&&u.jsx(lt,{onClick:()=>J(j.message),size:"small",sx:{ml:1},children:H(j.message)})]}),primaryTypographyProps:{sx:{color:j.sender==="user"?"common.white":"text.primary",bgcolor:j.sender==="user"?"primary.main":"grey.200",borderRadius:"16px",px:2,py:1,display:"inline-block"}}}),j.sender==="user"&&u.jsx(Er,{sx:{width:36,height:36,ml:1},children:u.jsx(cd,{})})]})},A))})]}),u.jsx(Wi,{}),u.jsxs(et,{sx:{p:2,pb:1,display:"flex",alignItems:"center",bgcolor:"background.paper"},children:[u.jsx(at,{fullWidth:!0,variant:"outlined",placeholder:"Type your message here...",value:l,onChange:N,disabled:g,sx:{mr:1,flexGrow:1},InputProps:{endAdornment:u.jsx(Ic,{position:"end",children:u.jsxs(lt,{onClick:m?L:T,color:"primary.main","aria-label":m?"Stop recording":"Start recording",size:"large",edge:"end",disabled:g,children:[m?u.jsx(Nm,{size:"small"}):u.jsx(Lm,{size:"small"}),m&&u.jsx(_n,{size:30,sx:{color:"primary.main",position:"absolute",zIndex:1}})]})})}}),g?u.jsx(_n,{size:24}):u.jsx(Rt,{variant:"contained",color:"primary",onClick:$,disabled:g||!l.trim(),endIcon:u.jsx(oa,{}),children:"Send"})]})]}),u.jsx(yo,{open:P,autoHideDuration:6e3,onClose:I,children:u.jsx(xr,{elevation:6,variant:"filled",onClose:I,severity:F,children:D})})]})]})};var Wm={},DN=Te;Object.defineProperty(Wm,"__esModule",{value:!0});var p2=Wm.default=void 0,zN=DN(Me()),BN=u;p2=Wm.default=(0,zN.default)((0,BN.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2M9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9zm9 14H6V10h12zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2"}),"LockOutlined");var Vm={},FN=Te;Object.defineProperty(Vm,"__esModule",{value:!0});var h2=Vm.default=void 0,UN=FN(Me()),WN=u;h2=Vm.default=(0,UN.default)((0,WN.jsx)("path",{d:"M15 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m-9-2V7H4v3H1v2h3v3h2v-3h3v-2zm9 4c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4"}),"PersonAdd");var Hm={},VN=Te;Object.defineProperty(Hm,"__esModule",{value:!0});var Ac=Hm.default=void 0,HN=VN(Me()),qN=u;Ac=Hm.default=(0,HN.default)((0,qN.jsx)("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3z"}),"VisibilityOff");const Ry=Ht(u.jsx("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility"),Py=Ht(u.jsx("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3z"}),"VisibilityOff");var qm={},GN=Te;Object.defineProperty(qm,"__esModule",{value:!0});var Gm=qm.default=void 0,KN=GN(Me()),YN=u;Gm=qm.default=(0,KN.default)((0,YN.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z"}),"Info");const sf=zs({palette:{primary:{main:"#556cd6"},secondary:{main:"#19857b"},background:{default:"linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)",paper:"#fff"}},typography:{fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif',h5:{fontWeight:600,color:"#444"},button:{textTransform:"none",fontWeight:"bold"}},components:{MuiButton:{styleOverrides:{root:{margin:"8px"}}}}}),XN=ie(En)(({theme:e})=>({marginTop:e.spacing(12),display:"flex",flexDirection:"column",alignItems:"center",padding:e.spacing(4),borderRadius:e.shape.borderRadius,boxShadow:e.shadows[10],width:"90%",maxWidth:"450px",opacity:.98,backdropFilter:"blur(10px)"}));function QN(){const e=qo(),[t,n]=p.useState(!1),{setUser:r}=p.useContext(vr),[o,i]=p.useState(0),[a,s]=p.useState(""),[l,c]=p.useState(""),[d,f]=p.useState(!1),[m,w]=p.useState(""),[y,x]=p.useState(!1),[k,g]=p.useState(""),[h,b]=p.useState(""),[C,R]=p.useState(""),[E,P]=p.useState(""),[M,D]=p.useState(""),[O,F]=p.useState(!1),[V,U]=p.useState(!1),[q,ee]=p.useState(""),[J,re]=p.useState("info"),I=[{id:"job_search",name:"Stress from job search"},{id:"classwork",name:"Stress from classwork"},{id:"social_anxiety",name:"Social anxiety"},{id:"impostor_syndrome",name:"Impostor Syndrome"},{id:"career_drift",name:"Career Drift"}],[B,$]=p.useState([]),v=A=>{const G=A.target.value,Y=B.includes(G)?B.filter(K=>K!==G):[...B,G];$(Y)},T=async A=>{var G,Y;A.preventDefault(),F(!0);try{const K=await Oe.post("/api/user/login",{username:a,password:m});if(K&&K.data){const oe=K.data.userId;localStorage.setItem("token",K.data.access_token),console.log("Token stored:",localStorage.getItem("token")),ee("Login successful!"),re("success"),n(!0),r({userId:oe}),e("/"),console.log("User logged in:",oe)}else throw new Error("Invalid response from server")}catch(K){console.error("Login failed:",K),ee("Login failed: "+(((Y=(G=K.response)==null?void 0:G.data)==null?void 0:Y.msg)||"Unknown error")),re("error"),f(!0)}U(!0),F(!1)},L=async A=>{var G,Y;A.preventDefault(),F(!0);try{const K=await Oe.post("/api/user/signup",{username:a,email:l,password:m,name:k,age:h,gender:C,placeOfResidence:E,fieldOfWork:M,mental_health_concerns:B});if(K&&K.data){const oe=K.data.userId;localStorage.setItem("token",K.data.access_token),console.log("Token stored:",localStorage.getItem("token")),ee("User registered successfully!"),re("success"),n(!0),r({userId:oe}),e("/"),console.log("User registered:",oe)}else throw new Error("Invalid response from server")}catch(K){console.error("Signup failed:",K),ee(((Y=(G=K.response)==null?void 0:G.data)==null?void 0:Y.error)||"Failed to register user."),re("error")}F(!1),U(!0)},_=async A=>{var G,Y;A.preventDefault(),F(!0);try{const K=await Oe.post("/api/user/anonymous_signin");if(K&&K.data)localStorage.setItem("token",K.data.access_token),console.log("Token stored:",localStorage.getItem("token")),ee("Anonymous sign-in successful!"),re("success"),n(!0),r({userId:null}),e("/");else throw new Error("Invalid response from server")}catch(K){console.error("Anonymous sign-in failed:",K),ee("Anonymous sign-in failed: "+(((Y=(G=K.response)==null?void 0:G.data)==null?void 0:Y.msg)||"Unknown error")),re("error")}F(!1),U(!0)},N=(A,G)=>{i(G)},H=(A,G)=>{G!=="clickaway"&&U(!1)},j=()=>{x(!y)};return u.jsxs(lm,{theme:sf,children:[u.jsx(Rm,{}),u.jsx(et,{sx:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:sf.palette.background.default},children:u.jsxs(XN,{children:[u.jsxs(f2,{value:o,onChange:N,variant:"fullWidth",centered:!0,indicatorColor:"primary",textColor:"primary",children:[u.jsx(ql,{icon:u.jsx(p2,{}),label:"Login"}),u.jsx(ql,{icon:u.jsx(h2,{}),label:"Sign Up"}),u.jsx(ql,{icon:u.jsx(Ac,{}),label:"Anonymous"})]}),u.jsxs(et,{sx:{mt:3,width:"100%",px:3},children:[o===0&&u.jsxs("form",{onSubmit:T,children:[u.jsx(at,{label:"Username",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:a,onChange:A=>s(A.target.value)}),u.jsx(at,{label:"Password",type:y?"text":"password",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:m,onChange:A=>w(A.target.value),InputProps:{endAdornment:u.jsx(lt,{onClick:j,edge:"end",children:y?u.jsx(Py,{}):u.jsx(Ry,{})})}}),u.jsxs(Rt,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,sx:{mt:2,maxWidth:"325px"},disabled:O,children:[O?u.jsx(_n,{size:24}):"Login"," "]}),d&&u.jsxs(Ie,{variant:"body2",textAlign:"center",sx:{mt:2},children:["Forgot your password? ",u.jsx(Rb,{to:"/request_reset",style:{textDecoration:"none",color:sf.palette.secondary.main},children:"Reset it here"})]})]}),o===1&&u.jsxs("form",{onSubmit:L,children:[u.jsx(at,{label:"Username",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:a,onChange:A=>s(A.target.value)}),u.jsx(at,{label:"Email",type:"email",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:l,onChange:A=>c(A.target.value)}),u.jsx(at,{label:"Password",type:y?"text":"password",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:m,onChange:A=>w(A.target.value),InputProps:{endAdornment:u.jsx(lt,{onClick:j,edge:"end",children:y?u.jsx(Py,{}):u.jsx(Ry,{})})}}),u.jsx(at,{label:"Name",variant:"outlined",margin:"normal",fullWidth:!0,value:k,onChange:A=>g(A.target.value)}),u.jsx(at,{label:"Age",type:"number",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:h,onChange:A=>b(A.target.value)}),u.jsxs(sd,{required:!0,fullWidth:!0,margin:"normal",children:[u.jsx(ld,{children:"Gender"}),u.jsxs(Vs,{value:C,label:"Gender",onChange:A=>R(A.target.value),children:[u.jsx(Zn,{value:"",children:"Select Gender"}),u.jsx(Zn,{value:"male",children:"Male"}),u.jsx(Zn,{value:"female",children:"Female"}),u.jsx(Zn,{value:"other",children:"Other"})]})]}),u.jsx(at,{label:"Place of Residence",variant:"outlined",margin:"normal",fullWidth:!0,value:E,onChange:A=>P(A.target.value)}),u.jsx(at,{label:"Field of Work",variant:"outlined",margin:"normal",fullWidth:!0,value:M,onChange:A=>D(A.target.value)}),u.jsxs(o2,{sx:{marginTop:"10px"},children:[u.jsx(Ie,{variant:"body1",gutterBottom:!0,children:"Select any mental stressors you are currently experiencing to help us better tailor your therapy sessions."}),I.map(A=>u.jsx(Tm,{control:u.jsx(km,{checked:B.includes(A.id),onChange:v,value:A.id}),label:u.jsxs(et,{display:"flex",alignItems:"center",children:[A.name,u.jsx(Ln,{title:u.jsx(Ie,{variant:"body2",children:JN(A.id)}),arrow:!0,placement:"right",children:u.jsx(Gm,{color:"action",style:{marginLeft:4,fontSize:20}})})]})},A.id))]}),u.jsx(Rt,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,sx:{mt:2},disabled:O,children:O?u.jsx(_n,{size:24}):"Sign Up"})]}),o===2&&u.jsx("form",{onSubmit:_,children:u.jsx(Rt,{type:"submit",variant:"outlined",color:"secondary",fullWidth:!0,sx:{mt:2},disabled:O,children:O?u.jsx(_n,{size:24}):"Anonymous Sign-In"})})]}),u.jsx(yo,{open:V,autoHideDuration:6e3,onClose:H,children:u.jsx(xr,{onClose:H,severity:J,sx:{width:"100%"},children:q})})]})})]})}function JN(e){switch(e){case"job_search":return"Feelings of stress stemming from the job search process.";case"classwork":return"Stress related to managing coursework and academic responsibilities.";case"social_anxiety":return"Anxiety experienced during social interactions or in anticipation of social interactions.";case"impostor_syndrome":return"Persistent doubt concerning one's abilities or accomplishments coupled with a fear of being exposed as a fraud.";case"career_drift":return"Stress from uncertainty or dissatisfaction with one's career path or progress.";default:return"No description available."}}var Km={},ZN=Te;Object.defineProperty(Km,"__esModule",{value:!0});var m2=Km.default=void 0,e6=ZN(Me()),t6=u;m2=Km.default=(0,e6.default)((0,t6.jsx)("path",{d:"M12.65 10C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H17v4h4v-4h2v-4zM7 14c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2"}),"VpnKey");var Ym={},n6=Te;Object.defineProperty(Ym,"__esModule",{value:!0});var g2=Ym.default=void 0,r6=n6(Me()),o6=u;g2=Ym.default=(0,r6.default)((0,o6.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1z"}),"Lock");const Ey=zs({palette:{primary:{main:"#3F51B5"},secondary:{main:"#F6AE2D"}}}),i6=()=>{const{changePassword:e}=p.useContext(vr),[t,n]=p.useState(""),[r,o]=p.useState(""),[i,a]=p.useState(!1),[s,l]=p.useState(""),[c,d]=p.useState("success"),{userId:f}=Ms(),m=async w=>{w.preventDefault();const y=await e(f,t,r);l(y.message),d(y.success?"success":"error"),a(!0)};return u.jsx(lm,{theme:Ey,children:u.jsx(Zw,{component:"main",maxWidth:"xs",sx:{background:"#fff",borderRadius:"8px",boxShadow:"0px 2px 4px rgba(0,0,0,0.2)"},children:u.jsxs(et,{sx:{marginTop:8,display:"flex",flexDirection:"column",alignItems:"center"},children:[u.jsx(Ie,{component:"h1",variant:"h5",children:"Update Password"}),u.jsxs("form",{onSubmit:m,style:{width:"100%",marginTop:Ey.spacing(1)},children:[u.jsx(at,{variant:"outlined",margin:"normal",required:!0,fullWidth:!0,id:"current-password",label:"Current Password",name:"currentPassword",autoComplete:"current-password",type:"password",value:t,onChange:w=>n(w.target.value),InputProps:{startAdornment:u.jsx(g2,{color:"primary",style:{marginRight:"10px"}})}}),u.jsx(at,{variant:"outlined",margin:"normal",required:!0,fullWidth:!0,id:"new-password",label:"New Password",name:"newPassword",autoComplete:"new-password",type:"password",value:r,onChange:w=>o(w.target.value),InputProps:{startAdornment:u.jsx(m2,{color:"secondary",style:{marginRight:"10px"}})}}),u.jsx(Rt,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:3,mb:2},children:"Update Password"})]}),u.jsx(yo,{open:i,autoHideDuration:6e3,onClose:()=>a(!1),children:u.jsx(xr,{onClose:()=>a(!1),severity:c,sx:{width:"100%"},children:s})})]})})})};var Xm={},a6=Te;Object.defineProperty(Xm,"__esModule",{value:!0});var v2=Xm.default=void 0,s6=a6(Me()),l6=u;v2=Xm.default=(0,s6.default)((0,l6.jsx)("path",{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 4-8 5-8-5V6l8 5 8-5z"}),"Email");var Qm={},c6=Te;Object.defineProperty(Qm,"__esModule",{value:!0});var y2=Qm.default=void 0,u6=c6(Me()),d6=u;y2=Qm.default=(0,u6.default)((0,d6.jsx)("path",{d:"M12 6c1.11 0 2-.9 2-2 0-.38-.1-.73-.29-1.03L12 0l-1.71 2.97c-.19.3-.29.65-.29 1.03 0 1.1.9 2 2 2m4.6 9.99-1.07-1.07-1.08 1.07c-1.3 1.3-3.58 1.31-4.89 0l-1.07-1.07-1.09 1.07C6.75 16.64 5.88 17 4.96 17c-.73 0-1.4-.23-1.96-.61V21c0 .55.45 1 1 1h16c.55 0 1-.45 1-1v-4.61c-.56.38-1.23.61-1.96.61-.92 0-1.79-.36-2.44-1.01M18 9h-5V7h-2v2H6c-1.66 0-3 1.34-3 3v1.54c0 1.08.88 1.96 1.96 1.96.52 0 1.02-.2 1.38-.57l2.14-2.13 2.13 2.13c.74.74 2.03.74 2.77 0l2.14-2.13 2.13 2.13c.37.37.86.57 1.38.57 1.08 0 1.96-.88 1.96-1.96V12C21 10.34 19.66 9 18 9"}),"Cake");var Jm={},f6=Te;Object.defineProperty(Jm,"__esModule",{value:!0});var x2=Jm.default=void 0,p6=f6(Me()),h6=u;x2=Jm.default=(0,p6.default)((0,h6.jsx)("path",{d:"M5.5 22v-7.5H4V9c0-1.1.9-2 2-2h3c1.1 0 2 .9 2 2v5.5H9.5V22zM18 22v-6h3l-2.54-7.63C18.18 7.55 17.42 7 16.56 7h-.12c-.86 0-1.63.55-1.9 1.37L12 16h3v6zM7.5 6c1.11 0 2-.89 2-2s-.89-2-2-2-2 .89-2 2 .89 2 2 2m9 0c1.11 0 2-.89 2-2s-.89-2-2-2-2 .89-2 2 .89 2 2 2"}),"Wc");var Zm={},m6=Te;Object.defineProperty(Zm,"__esModule",{value:!0});var b2=Zm.default=void 0,g6=m6(Me()),v6=u;b2=Zm.default=(0,g6.default)((0,v6.jsx)("path",{d:"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"}),"Home");var eg={},y6=Te;Object.defineProperty(eg,"__esModule",{value:!0});var w2=eg.default=void 0,x6=y6(Me()),b6=u;w2=eg.default=(0,x6.default)((0,b6.jsx)("path",{d:"M20 6h-4V4c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2m-6 0h-4V4h4z"}),"Work");var tg={},w6=Te;Object.defineProperty(tg,"__esModule",{value:!0});var ng=tg.default=void 0,S6=w6(Me()),C6=u;ng=tg.default=(0,S6.default)((0,C6.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6m0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20"}),"AccountCircle");var rg={},k6=Te;Object.defineProperty(rg,"__esModule",{value:!0});var S2=rg.default=void 0,R6=k6(Me()),P6=u;S2=rg.default=(0,R6.default)((0,P6.jsx)("path",{d:"M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8z"}),"Update");const E6=ie(f2)({background:"#fff",borderRadius:"8px",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",margin:"20px 0",maxWidth:"100%",overflow:"hidden"}),Ty=ie(ql)({fontSize:"1rem",fontWeight:"bold",color:"#3F51B5",marginRight:"4px",marginLeft:"4px",flex:1,maxWidth:"none","&.Mui-selected":{color:"#F6AE2D",background:"#e0e0e0"},"&:hover":{background:"#f4f4f4",transition:"background-color 0.3s"},"@media (max-width: 720px)":{padding:"6px 12px",fontSize:"0.8rem"}}),T6=zs({palette:{primary:{main:"#3F51B5"},secondary:{main:"#F6AE2D"},background:{default:"#e0e0e0"}},typography:{fontFamily:'"Open Sans", "Helvetica", "Arial", sans-serif',button:{textTransform:"none",fontWeight:"bold"}},components:{MuiButton:{styleOverrides:{root:{boxShadow:"none",borderRadius:8,"&:hover":{boxShadow:"0px 2px 4px rgba(0,0,0,0.2)"}}}},MuiPaper:{styleOverrides:{root:{padding:"20px",borderRadius:"10px",boxShadow:"0px 4px 12px rgba(0,0,0,0.1)"}}}}}),$6=ie(En)(({theme:e})=>({marginTop:e.spacing(2),padding:e.spacing(2),display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(2),boxShadow:e.shadows[3]}));function j6(){const{userId:e}=Ms(),[t,n]=p.useState({username:"",name:"",email:"",age:"",gender:"",placeOfResidence:"",fieldOfWork:"",mental_health_concerns:[]}),[r,o]=p.useState(0),i=(g,h)=>{o(h)},[a,s]=p.useState(""),[l,c]=p.useState(!1),[d,f]=p.useState("info");p.useEffect(()=>{if(!e){console.error("User ID is undefined");return}(async()=>{try{const h=await Oe.get(`/api/user/profile/${e}`);console.log("Fetched data:",h.data);const b={username:h.data.username||"",name:h.data.name||"",email:h.data.email||"",age:h.data.age||"",gender:h.data.gender||"",placeOfResidence:h.data.placeOfResidence||"Not specified",fieldOfWork:h.data.fieldOfWork||"Not specified",mental_health_concerns:h.data.mental_health_concerns||[]};console.log("Formatted data:",b),n(b)}catch{s("Failed to fetch user data"),f("error"),c(!0)}})()},[e]);const m=[{label:"Stress from Job Search",value:"job_search"},{label:"Stress from Classwork",value:"classwork"},{label:"Social Anxiety",value:"social_anxiety"},{label:"Impostor Syndrome",value:"impostor_syndrome"},{label:"Career Drift",value:"career_drift"}];console.log("current mental health concerns: ",t.mental_health_concerns);const w=g=>{const{name:h,checked:b}=g.target;n(C=>{const R=b?[...C.mental_health_concerns,h]:C.mental_health_concerns.filter(E=>E!==h);return{...C,mental_health_concerns:R}})},y=g=>{const{name:h,value:b}=g.target;n(C=>({...C,[h]:b}))},x=async g=>{g.preventDefault();try{await Oe.patch(`/api/user/profile/${e}`,t),s("Profile updated successfully!"),f("success")}catch{s("Failed to update profile"),f("error")}c(!0)},k=()=>{c(!1)};return u.jsxs(lm,{theme:T6,children:[u.jsx(Rm,{}),u.jsxs(Zw,{component:"main",maxWidth:"md",children:[u.jsxs(E6,{value:r,onChange:i,centered:!0,children:[u.jsx(Ty,{label:"Profile"}),u.jsx(Ty,{label:"Update Password"})]}),r===0&&u.jsxs($6,{component:"form",onSubmit:x,sx:{maxHeight:"81vh",overflow:"auto"},children:[u.jsxs(Ie,{variant:"h5",style:{fontWeight:700},children:[u.jsx(ng,{style:{marginRight:"10px"}})," ",t.username]}),u.jsx(at,{fullWidth:!0,label:"Name",variant:"outlined",name:"name",value:t.name||"",onChange:y,InputProps:{startAdornment:u.jsx(lt,{position:"start",children:u.jsx(cd,{})})}}),u.jsx(at,{fullWidth:!0,label:"Email",variant:"outlined",name:"email",value:t.email||"",onChange:y,InputProps:{startAdornment:u.jsx(lt,{position:"start",children:u.jsx(v2,{})})}}),u.jsx(at,{fullWidth:!0,label:"Age",variant:"outlined",name:"age",type:"number",value:t.age||"",onChange:y,InputProps:{startAdornment:u.jsx(lt,{children:u.jsx(y2,{})})}}),u.jsxs(sd,{fullWidth:!0,children:[u.jsx(ld,{children:"Gender"}),u.jsxs(Vs,{name:"gender",value:t.gender||"",label:"Gender",onChange:y,startAdornment:u.jsx(lt,{children:u.jsx(x2,{})}),children:[u.jsx(Zn,{value:"male",children:"Male"}),u.jsx(Zn,{value:"female",children:"Female"}),u.jsx(Zn,{value:"other",children:"Other"})]})]}),u.jsx(at,{fullWidth:!0,label:"Place of Residence",variant:"outlined",name:"placeOfResidence",value:t.placeOfResidence||"",onChange:y,InputProps:{startAdornment:u.jsx(lt,{children:u.jsx(b2,{})})}}),u.jsx(at,{fullWidth:!0,label:"Field of Work",variant:"outlined",name:"fieldOfWork",value:t.fieldOfWork||"",onChange:y,InputProps:{startAdornment:u.jsx(lt,{position:"start",children:u.jsx(w2,{})})}}),u.jsx(o2,{children:m.map((g,h)=>(console.log(`Is "${g.label}" checked?`,t.mental_health_concerns.includes(g.value)),u.jsx(Tm,{control:u.jsx(km,{checked:t.mental_health_concerns.includes(g.value),onChange:w,name:g.value}),label:u.jsxs(et,{display:"flex",alignItems:"center",children:[g.label,u.jsx(Ln,{title:u.jsx(Ie,{variant:"body2",children:M6(g.value)}),arrow:!0,placement:"right",children:u.jsx(Gm,{color:"action",style:{marginLeft:4,fontSize:20}})})]})},h)))}),u.jsxs(Rt,{type:"submit",color:"primary",variant:"contained",children:[u.jsx(S2,{style:{marginRight:"10px"}}),"Update Profile"]})]}),r===1&&u.jsx(i6,{userId:e}),u.jsx(yo,{open:l,autoHideDuration:6e3,onClose:k,children:u.jsx(xr,{onClose:k,severity:d,sx:{width:"100%"},children:a})})]})]})}function M6(e){switch(e){case"job_search":return"Feelings of stress stemming from the job search process.";case"classwork":return"Stress related to managing coursework and academic responsibilities.";case"social_anxiety":return"Anxiety experienced during social interactions or in anticipation of social interactions.";case"impostor_syndrome":return"Persistent doubt concerning one's abilities or accomplishments coupled with a fear of being exposed as a fraud.";case"career_drift":return"Stress from uncertainty or dissatisfaction with one's career path or progress.";default:return"No description available."}}var og={},O6=Te;Object.defineProperty(og,"__esModule",{value:!0});var C2=og.default=void 0,I6=O6(Me()),$y=u;C2=og.default=(0,I6.default)([(0,$y.jsx)("path",{d:"M22 9 12 2 2 9h9v13h2V9z"},"0"),(0,$y.jsx)("path",{d:"m4.14 12-1.96.37.82 4.37V22h2l.02-4H7v4h2v-6H4.9zm14.96 4H15v6h2v-4h1.98l.02 4h2v-5.26l.82-4.37-1.96-.37z"},"1")],"Deck");var ig={},_6=Te;Object.defineProperty(ig,"__esModule",{value:!0});var k2=ig.default=void 0,L6=_6(Me()),A6=u;k2=ig.default=(0,L6.default)((0,A6.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5m-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11m3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5"}),"InsertEmoticon");var ag={},N6=Te;Object.defineProperty(ag,"__esModule",{value:!0});var sg=ag.default=void 0,D6=N6(Me()),z6=u;sg=ag.default=(0,D6.default)((0,z6.jsx)("path",{d:"M19 5v14H5V5zm1.1-2H3.9c-.5 0-.9.4-.9.9v16.2c0 .4.4.9.9.9h16.2c.4 0 .9-.5.9-.9V3.9c0-.5-.5-.9-.9-.9M11 7h6v2h-6zm0 4h6v2h-6zm0 4h6v2h-6zM7 7h2v2H7zm0 4h2v2H7zm0 4h2v2H7z"}),"ListAlt");var lg={},B6=Te;Object.defineProperty(lg,"__esModule",{value:!0});var R2=lg.default=void 0,F6=B6(Me()),U6=u;R2=lg.default=(0,F6.default)((0,U6.jsx)("path",{d:"M10.09 15.59 11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2"}),"ExitToApp");var cg={},W6=Te;Object.defineProperty(cg,"__esModule",{value:!0});var P2=cg.default=void 0,V6=W6(Me()),H6=u;P2=cg.default=(0,V6.default)((0,H6.jsx)("path",{d:"M16.53 11.06 15.47 10l-4.88 4.88-2.12-2.12-1.06 1.06L10.59 17zM19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 16H5V8h14z"}),"EventAvailable");var ug={},q6=Te;Object.defineProperty(ug,"__esModule",{value:!0});var E2=ug.default=void 0,G6=q6(Me()),jy=u;E2=ug.default=(0,G6.default)([(0,jy.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),(0,jy.jsx)("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"Schedule");var dg={},K6=Te;Object.defineProperty(dg,"__esModule",{value:!0});var T2=dg.default=void 0,Y6=K6(Me()),X6=u;T2=dg.default=(0,Y6.default)((0,X6.jsx)("path",{d:"m22.69 18.37 1.14-1-1-1.73-1.45.49c-.32-.27-.68-.48-1.08-.63L20 14h-2l-.3 1.49c-.4.15-.76.36-1.08.63l-1.45-.49-1 1.73 1.14 1c-.08.5-.08.76 0 1.26l-1.14 1 1 1.73 1.45-.49c.32.27.68.48 1.08.63L18 24h2l.3-1.49c.4-.15.76-.36 1.08-.63l1.45.49 1-1.73-1.14-1c.08-.51.08-.77 0-1.27M19 21c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2M11 7v5.41l2.36 2.36 1.04-1.79-1.4-1.39V7zm10 5c0-4.97-4.03-9-9-9-2.83 0-5.35 1.32-7 3.36V4H3v6h6V8H6.26C7.53 6.19 9.63 5 12 5c3.86 0 7 3.14 7 7zm-10.14 6.91c-2.99-.49-5.35-2.9-5.78-5.91H3.06c.5 4.5 4.31 8 8.94 8h.07z"}),"ManageHistory");const My=230;function Q6(){const{logout:e,user:t}=p.useContext(vr),n=ho(),r=i=>n.pathname===i,o=[{text:"Mind Chat",icon:u.jsx(C2,{}),path:"/"},...t!=null&&t.userId?[{text:"Track Your Vibes",icon:u.jsx(k2,{}),path:"/user/mood_logging"},{text:"Mood Logs",icon:u.jsx(sg,{}),path:"/user/mood_logs"},{text:"Schedule Check-In",icon:u.jsx(E2,{}),path:"/user/check_in"},{text:"Check-In Reporting",icon:u.jsx(P2,{}),path:`/user/check_ins/${t==null?void 0:t.userId}`},{text:"Chat Log Manager",icon:u.jsx(T2,{}),path:"/user/chat_log_Manager"}]:[]];return u.jsx(UI,{sx:{width:My,flexShrink:0,mt:8,"& .MuiDrawer-paper":{width:My,boxSizing:"border-box",position:"relative",height:"91vh",top:0,overflowX:"hidden",borderRadius:2,boxShadow:1}},variant:"permanent",anchor:"left",children:u.jsxs(Ws,{children:[o.map(i=>u.jsx(VP,{to:i.path,style:{textDecoration:"none",color:"inherit"},children:u.jsxs(_c,{button:!0,sx:{backgroundColor:r(i.path)?"rgba(25, 118, 210, 0.5)":"inherit","&:hover":{bgcolor:"grey.200"}},children:[u.jsx(dy,{children:i.icon}),u.jsx(ws,{primary:i.text})]})},i.text)),u.jsxs(_c,{button:!0,onClick:e,children:[u.jsx(dy,{children:u.jsx(R2,{})}),u.jsx(ws,{primary:"Logout"})]})]})})}var fg={},J6=Te;Object.defineProperty(fg,"__esModule",{value:!0});var $2=fg.default=void 0,Z6=J6(Me()),eD=u;$2=fg.default=(0,Z6.default)((0,eD.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");var pg={},tD=Te;Object.defineProperty(pg,"__esModule",{value:!0});var j2=pg.default=void 0,nD=tD(Me()),rD=u;j2=pg.default=(0,nD.default)((0,rD.jsx)("path",{d:"M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2m6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1z"}),"Notifications");var hg={},oD=Te;Object.defineProperty(hg,"__esModule",{value:!0});var M2=hg.default=void 0,iD=oD(Me()),aD=u;M2=hg.default=(0,iD.default)((0,aD.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12z"}),"Cancel");function sD({toggleSidebar:e}){const{incrementNotificationCount:t,notifications:n,addNotification:r,removeNotification:o}=p.useContext(vr),i=qo(),{user:a}=p.useContext(vr),[s,l]=p.useState(null),c=localStorage.getItem("token"),d=a==null?void 0:a.userId;console.log("User ID:",d),p.useEffect(()=>{d?f():console.error("No user ID available from URL parameters.")},[d]);const f=async()=>{if(!d){console.error("User ID is missing in context");return}try{const k=(await Oe.get(`/api/check-in/missed?user_id=${d}`,{headers:{Authorization:`Bearer ${c}`}})).data;console.log("Missed check-ins:",k),k.length>0?k.forEach(g=>{r({title:`Missed Check-in on ${new Date(g.check_in_time).toLocaleString()}`,message:"Please complete your check-in."})}):r({title:"You have no missed check-ins.",message:""})}catch(x){console.error("Failed to fetch missed check-ins:",x),r({title:"Failed to fetch missed check-ins. Please check the console for more details.",message:""})}},m=x=>{l(x.currentTarget)},w=x=>{l(null),o(x)},y=()=>{a&&a.userId?i(`/user/profile/${a.userId}`):console.error("User ID not found")};return p.useEffect(()=>{const x=k=>{k.data&&k.data.msg==="updateCount"&&(console.log("Received message from service worker:",k.data),r({title:k.data.title,message:k.data.body}),t())};return navigator.serviceWorker.addEventListener("message",x),()=>{navigator.serviceWorker.removeEventListener("message",x)}},[]),u.jsx(kj,{position:"fixed",sx:{zIndex:x=>x.zIndex.drawer+1},children:u.jsxs(BA,{children:[u.jsx(lt,{onClick:e,color:"inherit",edge:"start",sx:{marginRight:2},children:u.jsx($2,{})}),u.jsx(Ie,{variant:"h6",noWrap:!0,component:"div",sx:{flexGrow:1},children:"Dashboard"}),(a==null?void 0:a.userId)&&u.jsx(lt,{color:"inherit",onClick:m,children:u.jsx(i3,{badgeContent:n.length,color:"secondary",children:u.jsx(j2,{})})}),u.jsx(l2,{anchorEl:s,open:!!s,onClose:()=>w(null),children:n.map((x,k)=>u.jsx(Zn,{onClick:()=>w(k),sx:{whiteSpace:"normal",maxWidth:350,padding:1},children:u.jsxs(id,{elevation:2,sx:{display:"flex",alignItems:"center",width:"100%"},children:[u.jsx(M2,{color:"error"}),u.jsxs(Cm,{sx:{flex:"1 1 auto"},children:[u.jsx(Ie,{variant:"subtitle1",sx:{fontWeight:"bold"},children:x.title}),u.jsx(Ie,{variant:"body2",color:"text.secondary",children:x.message})]})]})},k))}),(a==null?void 0:a.userId)&&u.jsx(lt,{color:"inherit",onClick:y,children:u.jsx(ng,{})})]})})}var mg={},lD=Te;Object.defineProperty(mg,"__esModule",{value:!0});var O2=mg.default=void 0,cD=lD(Me()),uD=u;O2=mg.default=(0,cD.default)((0,uD.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M17 13l-5 5-5-5h3V9h4v4z"}),"CloudDownload");var gg={},dD=Te;Object.defineProperty(gg,"__esModule",{value:!0});var _p=gg.default=void 0,fD=dD(Me()),pD=u;_p=gg.default=(0,fD.default)((0,pD.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zm2.46-7.12 1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"}),"DeleteForever");var vg={},hD=Te;Object.defineProperty(vg,"__esModule",{value:!0});var I2=vg.default=void 0,mD=hD(Me()),gD=u;I2=vg.default=(0,mD.default)((0,gD.jsx)("path",{d:"M9 11H7v2h2zm4 0h-2v2h2zm4 0h-2v2h2zm2-7h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 16H5V9h14z"}),"DateRange");const vD=ie(En)(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadius,boxShadow:1,maxWidth:"100%",margin:"auto",marginTop:e.spacing(2),backgroundColor:"#fff",overflow:"auto"})),Cl=ie(Rt)(({theme:e})=>({margin:e.spacing(0),paddingLeft:e.spacing(1),paddingRight:e.spacing(3)}));function yD(){const[e,t]=nn.useState(!1),[n,r]=p.useState(!1),[o,i]=nn.useState(""),[a,s]=nn.useState("info"),[l,c]=p.useState(!1),[d,f]=p.useState(""),[m,w]=p.useState(""),[y,x]=p.useState(!1),k=(R,E)=>{E!=="clickaway"&&t(!1)},g=()=>{r(!1)},h=R=>{x(R),r(!0)},b=async(R=!1)=>{var E,P;c(!0);try{const M=R?"/api/user/download_chat_logs/range":"/api/user/download_chat_logs",D=R?{params:{start_date:d,end_date:m}}:{},O=await Oe.get(M,{...D,headers:{Authorization:`Bearer ${localStorage.getItem("token")}`},responseType:"blob"}),F=window.URL.createObjectURL(new Blob([O.data])),V=document.createElement("a");V.href=F,V.setAttribute("download",R?"chat_logs_range.csv":"chat_logs.csv"),document.body.appendChild(V),V.click(),i("Chat logs downloaded successfully."),s("success")}catch(M){i(`Failed to download chat logs: ${((P=(E=M.response)==null?void 0:E.data)==null?void 0:P.error)||M.message}`),s("error")}finally{c(!1)}t(!0)},C=async()=>{var R,E;r(!1),c(!0);try{const P=y?"/api/user/delete_chat_logs/range":"/api/user/delete_chat_logs",M=y?{params:{start_date:d,end_date:m}}:{},D=await Oe.delete(P,{...M,headers:{Authorization:`Bearer ${localStorage.getItem("token")}`}});i(D.data.message),s("success")}catch(P){i(`Failed to delete chat logs: ${((E=(R=P.response)==null?void 0:R.data)==null?void 0:E.error)||P.message}`),s("error")}finally{c(!1)}t(!0)};return u.jsxs(vD,{sx:{height:"91vh"},children:[u.jsx(Ie,{variant:"h4",gutterBottom:!0,children:"Manage Your Chat Logs"}),u.jsx(Ie,{variant:"body1",paragraph:!0,children:"Manage your chat logs efficiently by downloading or deleting entries for specific dates or entire ranges. Please be cautious as deletion is permanent."}),u.jsxs("div",{style:{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",gap:20},children:[u.jsxs("div",{style:{display:"flex",gap:10,marginBottom:20},children:[u.jsx(at,{label:"Start Date",type:"date",value:d,onChange:R=>f(R.target.value),InputLabelProps:{shrink:!0}}),u.jsx(at,{label:"End Date",type:"date",value:m,onChange:R=>w(R.target.value),InputLabelProps:{shrink:!0}})]}),u.jsx(Ie,{variant:"body1",paragraph:!0,children:"Here you can download your chat logs as a CSV file, which includes details like chat IDs, content, type, and additional information for each session."}),u.jsx(Ln,{title:"Download chat logs for selected date range",children:u.jsx(Cl,{variant:"outlined",startIcon:u.jsx(I2,{}),onClick:()=>b(!0),disabled:l||!d||!m,children:l?u.jsx(_n,{size:24,color:"inherit"}):"Download Range"})}),u.jsx(Ln,{title:"Download your chat logs as a CSV file",children:u.jsx(Cl,{variant:"contained",color:"primary",startIcon:u.jsx(O2,{}),onClick:()=>b(!1),disabled:l,children:l?u.jsx(_n,{size:24,color:"inherit"}):"Download Chat Logs"})}),u.jsx(Ie,{variant:"body1",paragraph:!0,children:"If you need to clear your history for privacy or other reasons, you can also permanently delete your chat logs from the server."}),u.jsx(Ln,{title:"Delete chat logs for selected date range",children:u.jsx(Cl,{variant:"outlined",color:"warning",startIcon:u.jsx(_p,{}),onClick:()=>h(!0),disabled:l||!d||!m,children:l?u.jsx(_n,{size:24,color:"inherit"}):"Delete Range"})}),u.jsx(Ln,{title:"Permanently delete all your chat logs",children:u.jsx(Cl,{variant:"contained",color:"secondary",startIcon:u.jsx(_p,{}),onClick:()=>h(!1),disabled:l,children:l?u.jsx(_n,{size:24,color:"inherit"}):"Delete Chat Logs"})}),u.jsx(Ie,{variant:"body1",paragraph:!0,children:"Please use these options carefully as deleting your chat logs is irreversible."})]}),u.jsxs($p,{open:n,onClose:g,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[u.jsx(Op,{id:"alert-dialog-title",children:"Confirm Deletion"}),u.jsx(Mp,{children:u.jsx(t2,{id:"alert-dialog-description",children:"Are you sure you want to delete these chat logs? This action cannot be undone."})}),u.jsxs(jp,{children:[u.jsx(Rt,{onClick:g,color:"primary",children:"Cancel"}),u.jsx(Rt,{onClick:()=>C(),color:"secondary",autoFocus:!0,children:"Confirm"})]})]}),u.jsx(yo,{open:e,autoHideDuration:6e3,onClose:k,children:u.jsx(xr,{onClose:k,severity:a,sx:{width:"100%"},children:o})})]})}const Oy=()=>{const{user:e,voiceEnabled:t,setVoiceEnabled:n}=p.useContext(vr),r=e==null?void 0:e.userId,[o,i]=p.useState(0),[a,s]=p.useState(0),[l,c]=p.useState(""),[d,f]=p.useState([]),[m,w]=p.useState(!1),[y,x]=p.useState(null),k=p.useRef([]),[g,h]=p.useState(!1),[b,C]=p.useState(!1),[R,E]=p.useState(""),[P,M]=p.useState("info"),[D,O]=p.useState(null),F=T=>{T.preventDefault(),n(!t)},V=T=>{if(!t||T===D){O(null),window.speechSynthesis.cancel();return}const L=window.speechSynthesis,_=new SpeechSynthesisUtterance(T),N=()=>{const H=L.getVoices();console.log(H.map(A=>`${A.name} - ${A.lang} - ${A.gender}`));const j=H.find(A=>A.name.includes("Microsoft Zira - English (United States)"));j?_.voice=j:console.log("No female voice found"),_.onend=()=>{O(null)},O(T),L.speak(_)};L.getVoices().length===0?L.onvoiceschanged=N:N()},U=(T,L)=>{L!=="clickaway"&&C(!1)},q=p.useCallback(async()=>{if(o!==null){h(!0);try{const T=await fetch(`/api/ai/mental_health/finalize/${r}/${o}`,{method:"POST",headers:{"Content-Type":"application/json"}}),L=await T.json();T.ok?(E("Chat finalized successfully"),M("success"),i(null),s(0),f([])):(E("Failed to finalize chat"),M("error"))}catch{E("Error finalizing chat"),M("error")}finally{h(!1),C(!0)}}},[r,o]),ee=p.useCallback(async()=>{if(l.trim()){console.log(o),h(!0);try{const T=JSON.stringify({prompt:l,turn_id:a}),L=await fetch(`/api/ai/mental_health/${r}/${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:T}),_=await L.json();console.log(_),L.ok?(f(N=>[...N,{message:l,sender:"user"},{message:_,sender:"agent"}]),s(N=>N+1),c("")):(console.error("Failed to send message:",_),E(_.error||"An error occurred while sending the message."),M("error"),C(!0))}catch(T){console.error("Failed to send message:",T),E("Network or server error occurred."),M("error"),C(!0)}finally{h(!1)}}},[l,r,o,a]),J=()=>MediaRecorder.isTypeSupported("audio/webm; codecs=opus")?"audio/webm; codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"audio/wav",re=()=>{navigator.mediaDevices.getUserMedia({audio:{sampleRate:44100,channelCount:1,volume:1,echoCancellation:!0}}).then(T=>{k.current=[];const L=J();let _=new MediaRecorder(T,{mimeType:L});_.ondataavailable=N=>{k.current.push(N.data)},_.start(),x(_),w(!0)}).catch(T=>{console.error("Error accessing microphone:",T)})},I=()=>{y&&(y.stream.getTracks().forEach(T=>T.stop()),y.onstop=()=>{const T=y.mimeType,L=new Blob(k.current,{type:T});B(L),w(!1),x(null)},y.stop())},B=T=>{if(T.size===0){console.error("Audio Blob is empty");return}const L=new FormData;L.append("audio",T),h(!0),Oe.post("/api/ai/mental_health/voice-to-text",L,{headers:{"Content-Type":"multipart/form-data"}}).then(_=>{const{message:N}=_.data;c(N),ee()}).catch(_=>{console.error("Error uploading audio:",_)}).finally(()=>{h(!1)})},$=p.useCallback(T=>{const L=T.target.value;L.split(/\s+/).length>200?(c(N=>N.split(/\s+/).slice(0,200).join(" ")),E("Word limit reached. Only 200 words allowed."),M("warning"),C(!0)):c(L)},[]),v=T=>T===D?u.jsx(Cs,{}):u.jsx(Ss,{});return u.jsxs(u.Fragment,{children:[u.jsx("style",{children:` + `}),u.jsxs(et,{sx:{maxWidth:"100%",mx:"auto",my:2,display:"flex",flexDirection:"column",height:"91vh",borderRadius:2,boxShadow:1},children:[u.jsxs(id,{sx:{display:"flex",flexDirection:"column",height:"100%",borderRadius:2,boxShadow:3},children:[u.jsxs(Cm,{sx:{flexGrow:1,overflow:"auto",padding:3,position:"relative"},children:[u.jsxs(et,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",position:"relative",marginBottom:"5px"},children:[u.jsx(Ln,{title:"Toggle voice responses",children:u.jsx(lt,{color:"inherit",onClick:ee,sx:{padding:0},children:u.jsx(d2,{checked:t,onChange:j=>n(j.target.checked),icon:u.jsx(Cs,{}),checkedIcon:u.jsx(Ss,{}),inputProps:{"aria-label":"Voice response toggle"},color:"default",sx:{height:42,"& .MuiSwitch-switchBase":{padding:"9px"},"& .MuiSwitch-switchBase.Mui-checked":{color:"white",transform:"translateX(16px)","& + .MuiSwitch-track":{backgroundColor:"primary.main"}}}})})}),u.jsx(Ln,{title:"Start a new chat",placement:"top",arrow:!0,children:u.jsx(lt,{"aria-label":"new chat",color:"primary",onClick:B,disabled:g,sx:{"&:hover":{backgroundColor:"primary.main",color:"common.white"}},children:u.jsx(Um,{})})})]}),u.jsx(Wi,{sx:{marginBottom:"10px"}}),b.length===0&&u.jsxs(et,{sx:{display:"flex",marginBottom:2,marginTop:3},children:[u.jsx(Er,{src:Pi,sx:{width:44,height:44,marginRight:2},alt:"Aria"}),u.jsx(Ie,{variant:"h4",component:"h1",gutterBottom:!0,children:"Welcome to Your Mental Health Companion"})]}),R?u.jsx(AN,{}):d.length===0&&u.jsxs(et,{sx:{display:"flex"},children:[u.jsx(Er,{src:Pi,sx:{width:36,height:36,marginRight:1},alt:"Aria"}),u.jsxs(Ie,{variant:"body1",gutterBottom:!0,sx:{bgcolor:"grey.200",borderRadius:"16px",px:2,py:1,display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"nowrap"},children:[b,t&&b&&u.jsx(lt,{onClick:()=>J(b),size:"small",sx:{ml:1},children:H(b)})]})]}),u.jsx(Ws,{sx:{maxHeight:"100%",overflow:"auto"},children:d.map((j,A)=>u.jsx(_c,{sx:{display:"flex",flexDirection:"column",alignItems:j.sender==="user"?"flex-end":"flex-start",borderRadius:2,mb:.5,p:1,border:"none","&:before":{display:"none"},"&:after":{display:"none"}},children:u.jsxs(et,{sx:{display:"flex",alignItems:"center",color:j.sender==="user"?"common.white":"text.primary",borderRadius:"16px"},children:[j.sender==="agent"&&u.jsx(Er,{src:Pi,sx:{width:36,height:36,mr:1},alt:"Aria"}),u.jsx(ws,{primary:u.jsxs(et,{sx:{display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"nowrap"},children:[j.message,t&&j.sender==="agent"&&u.jsx(lt,{onClick:()=>J(j.message),size:"small",sx:{ml:1},children:H(j.message)})]}),primaryTypographyProps:{sx:{color:j.sender==="user"?"common.white":"text.primary",bgcolor:j.sender==="user"?"primary.main":"grey.200",borderRadius:"16px",px:2,py:1,display:"inline-block"}}}),j.sender==="user"&&u.jsx(Er,{sx:{width:36,height:36,ml:1},children:u.jsx(cd,{})})]})},A))})]}),u.jsx(Wi,{}),u.jsxs(et,{sx:{p:2,pb:1,display:"flex",alignItems:"center",bgcolor:"background.paper"},children:[u.jsx(at,{fullWidth:!0,variant:"outlined",placeholder:"Type your message here...",value:l,onChange:N,disabled:g,sx:{mr:1,flexGrow:1},InputProps:{endAdornment:u.jsx(Ic,{position:"end",children:u.jsxs(lt,{onClick:m?L:T,color:"primary.main","aria-label":m?"Stop recording":"Start recording",size:"large",edge:"end",disabled:g,children:[m?u.jsx(Nm,{size:"small"}):u.jsx(Lm,{size:"small"}),m&&u.jsx(_n,{size:30,sx:{color:"primary.main",position:"absolute",zIndex:1}})]})})}}),g?u.jsx(_n,{size:24}):u.jsx(Rt,{variant:"contained",color:"primary",onClick:$,disabled:g||!l.trim(),endIcon:u.jsx(oa,{}),children:"Send"})]})]}),u.jsx(yo,{open:P,autoHideDuration:6e3,onClose:I,children:u.jsx(xr,{elevation:6,variant:"filled",onClose:I,severity:F,children:D})})]})]})};var Wm={},DN=Te;Object.defineProperty(Wm,"__esModule",{value:!0});var p2=Wm.default=void 0,zN=DN(Me()),BN=u;p2=Wm.default=(0,zN.default)((0,BN.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2M9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9zm9 14H6V10h12zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2"}),"LockOutlined");var Vm={},FN=Te;Object.defineProperty(Vm,"__esModule",{value:!0});var h2=Vm.default=void 0,UN=FN(Me()),WN=u;h2=Vm.default=(0,UN.default)((0,WN.jsx)("path",{d:"M15 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m-9-2V7H4v3H1v2h3v3h2v-3h3v-2zm9 4c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4"}),"PersonAdd");var Hm={},VN=Te;Object.defineProperty(Hm,"__esModule",{value:!0});var Ac=Hm.default=void 0,HN=VN(Me()),qN=u;Ac=Hm.default=(0,HN.default)((0,qN.jsx)("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3z"}),"VisibilityOff");const Ry=Ht(u.jsx("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility"),Py=Ht(u.jsx("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3z"}),"VisibilityOff");var qm={},GN=Te;Object.defineProperty(qm,"__esModule",{value:!0});var Gm=qm.default=void 0,KN=GN(Me()),YN=u;Gm=qm.default=(0,KN.default)((0,YN.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z"}),"Info");const sf=zs({palette:{primary:{main:"#556cd6"},secondary:{main:"#19857b"},background:{default:"linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)",paper:"#fff"}},typography:{fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif',h5:{fontWeight:600,color:"#444"},button:{textTransform:"none",fontWeight:"bold"}},components:{MuiButton:{styleOverrides:{root:{margin:"8px"}}}}}),XN=ie(En)(({theme:e})=>({marginTop:e.spacing(12),display:"flex",flexDirection:"column",alignItems:"center",padding:e.spacing(4),borderRadius:e.shape.borderRadius,boxShadow:e.shadows[10],width:"90%",maxWidth:"450px",opacity:.98,backdropFilter:"blur(10px)"}));function QN(){const e=qo(),[t,n]=p.useState(!1),{setUser:r}=p.useContext(vr),[o,i]=p.useState(0),[a,s]=p.useState(""),[l,c]=p.useState(""),[d,f]=p.useState(!1),[m,w]=p.useState(""),[y,x]=p.useState(!1),[k,g]=p.useState(""),[h,b]=p.useState(""),[C,R]=p.useState(""),[E,P]=p.useState(""),[M,D]=p.useState(""),[O,F]=p.useState(!1),[V,U]=p.useState(!1),[q,ee]=p.useState(""),[J,re]=p.useState("info"),I=[{id:"job_search",name:"Stress from job search"},{id:"classwork",name:"Stress from classwork"},{id:"social_anxiety",name:"Social anxiety"},{id:"impostor_syndrome",name:"Impostor Syndrome"},{id:"career_drift",name:"Career Drift"}],[B,$]=p.useState([]),v=A=>{const G=A.target.value,Y=B.includes(G)?B.filter(K=>K!==G):[...B,G];$(Y)},T=async A=>{var G,Y;A.preventDefault(),F(!0);try{const K=await Oe.post("/api/user/login",{username:a,password:m});if(K&&K.data){const oe=K.data.userId;localStorage.setItem("token",K.data.access_token),console.log("Token stored:",localStorage.getItem("token")),ee("Login successful!"),re("success"),n(!0),r({userId:oe}),e("/"),console.log("User logged in:",oe)}else throw new Error("Invalid response from server")}catch(K){console.error("Login failed:",K),ee("Login failed: "+(((Y=(G=K.response)==null?void 0:G.data)==null?void 0:Y.msg)||"Unknown error")),re("error"),f(!0)}U(!0),F(!1)},L=async A=>{var G,Y;A.preventDefault(),F(!0);try{const K=await Oe.post("/api/user/signup",{username:a,email:l,password:m,name:k,age:h,gender:C,placeOfResidence:E,fieldOfWork:M,mental_health_concerns:B});if(K&&K.data){const oe=K.data.userId;localStorage.setItem("token",K.data.access_token),console.log("Token stored:",localStorage.getItem("token")),ee("User registered successfully!"),re("success"),n(!0),r({userId:oe}),e("/"),console.log("User registered:",oe)}else throw new Error("Invalid response from server")}catch(K){console.error("Signup failed:",K),ee(((Y=(G=K.response)==null?void 0:G.data)==null?void 0:Y.error)||"Failed to register user."),re("error")}F(!1),U(!0)},_=async A=>{var G,Y;A.preventDefault(),F(!0);try{const K=await Oe.post("/api/user/anonymous_signin");if(K&&K.data)localStorage.setItem("token",K.data.access_token),console.log("Token stored:",localStorage.getItem("token")),ee("Anonymous sign-in successful!"),re("success"),n(!0),r({userId:null}),e("/");else throw new Error("Invalid response from server")}catch(K){console.error("Anonymous sign-in failed:",K),ee("Anonymous sign-in failed: "+(((Y=(G=K.response)==null?void 0:G.data)==null?void 0:Y.msg)||"Unknown error")),re("error")}F(!1),U(!0)},N=(A,G)=>{i(G)},H=(A,G)=>{G!=="clickaway"&&U(!1)},j=()=>{x(!y)};return u.jsxs(lm,{theme:sf,children:[u.jsx(Rm,{}),u.jsx(et,{sx:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:sf.palette.background.default},children:u.jsxs(XN,{children:[u.jsxs(f2,{value:o,onChange:N,variant:"fullWidth",centered:!0,indicatorColor:"primary",textColor:"primary",children:[u.jsx(ql,{icon:u.jsx(p2,{}),label:"Login"}),u.jsx(ql,{icon:u.jsx(h2,{}),label:"Sign Up"}),u.jsx(ql,{icon:u.jsx(Ac,{}),label:"Anonymous"})]}),u.jsxs(et,{sx:{mt:3,width:"100%",px:3},children:[o===0&&u.jsxs("form",{onSubmit:T,children:[u.jsx(at,{label:"Username",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:a,onChange:A=>s(A.target.value)}),u.jsx(at,{label:"Password",type:y?"text":"password",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:m,onChange:A=>w(A.target.value),InputProps:{endAdornment:u.jsx(lt,{onClick:j,edge:"end",children:y?u.jsx(Py,{}):u.jsx(Ry,{})})}}),u.jsxs(Rt,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,sx:{mt:2,maxWidth:"325px"},disabled:O,children:[O?u.jsx(_n,{size:24}):"Login"," "]}),d&&u.jsxs(Ie,{variant:"body2",textAlign:"center",sx:{mt:2},children:["Forgot your password? ",u.jsx(Rb,{to:"/request_reset",style:{textDecoration:"none",color:sf.palette.secondary.main},children:"Reset it here"})]})]}),o===1&&u.jsxs("form",{onSubmit:L,children:[u.jsx(at,{label:"Username",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:a,onChange:A=>s(A.target.value)}),u.jsx(at,{label:"Email",type:"email",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:l,onChange:A=>c(A.target.value)}),u.jsx(at,{label:"Password",type:y?"text":"password",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:m,onChange:A=>w(A.target.value),InputProps:{endAdornment:u.jsx(lt,{onClick:j,edge:"end",children:y?u.jsx(Py,{}):u.jsx(Ry,{})})}}),u.jsx(at,{label:"Name",variant:"outlined",margin:"normal",fullWidth:!0,value:k,onChange:A=>g(A.target.value)}),u.jsx(at,{label:"Age",type:"number",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,value:h,onChange:A=>b(A.target.value)}),u.jsxs(sd,{required:!0,fullWidth:!0,margin:"normal",children:[u.jsx(ld,{children:"Gender"}),u.jsxs(Vs,{value:C,label:"Gender",onChange:A=>R(A.target.value),children:[u.jsx(Zn,{value:"",children:"Select Gender"}),u.jsx(Zn,{value:"male",children:"Male"}),u.jsx(Zn,{value:"female",children:"Female"}),u.jsx(Zn,{value:"other",children:"Other"})]})]}),u.jsx(at,{label:"Place of Residence",variant:"outlined",margin:"normal",fullWidth:!0,value:E,onChange:A=>P(A.target.value)}),u.jsx(at,{label:"Field of Work",variant:"outlined",margin:"normal",fullWidth:!0,value:M,onChange:A=>D(A.target.value)}),u.jsxs(o2,{sx:{marginTop:"10px"},children:[u.jsx(Ie,{variant:"body1",gutterBottom:!0,children:"Select any mental stressors you are currently experiencing to help us better tailor your therapy sessions."}),I.map(A=>u.jsx(Tm,{control:u.jsx(km,{checked:B.includes(A.id),onChange:v,value:A.id}),label:u.jsxs(et,{display:"flex",alignItems:"center",children:[A.name,u.jsx(Ln,{title:u.jsx(Ie,{variant:"body2",children:JN(A.id)}),arrow:!0,placement:"right",children:u.jsx(Gm,{color:"action",style:{marginLeft:4,fontSize:20}})})]})},A.id))]}),u.jsx(Rt,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,sx:{mt:2},disabled:O,children:O?u.jsx(_n,{size:24}):"Sign Up"})]}),o===2&&u.jsx("form",{onSubmit:_,children:u.jsx(Rt,{type:"submit",variant:"outlined",color:"secondary",fullWidth:!0,sx:{mt:2},disabled:O,children:O?u.jsx(_n,{size:24}):"Anonymous Sign-In"})})]}),u.jsx(yo,{open:V,autoHideDuration:6e3,onClose:H,children:u.jsx(xr,{onClose:H,severity:J,sx:{width:"100%"},children:q})})]})})]})}function JN(e){switch(e){case"job_search":return"Feelings of stress stemming from the job search process.";case"classwork":return"Stress related to managing coursework and academic responsibilities.";case"social_anxiety":return"Anxiety experienced during social interactions or in anticipation of social interactions.";case"impostor_syndrome":return"Persistent doubt concerning one's abilities or accomplishments coupled with a fear of being exposed as a fraud.";case"career_drift":return"Stress from uncertainty or dissatisfaction with one's career path or progress.";default:return"No description available."}}var Km={},ZN=Te;Object.defineProperty(Km,"__esModule",{value:!0});var m2=Km.default=void 0,e6=ZN(Me()),t6=u;m2=Km.default=(0,e6.default)((0,t6.jsx)("path",{d:"M12.65 10C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H17v4h4v-4h2v-4zM7 14c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2"}),"VpnKey");var Ym={},n6=Te;Object.defineProperty(Ym,"__esModule",{value:!0});var g2=Ym.default=void 0,r6=n6(Me()),o6=u;g2=Ym.default=(0,r6.default)((0,o6.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1z"}),"Lock");const Ey=zs({palette:{primary:{main:"#3F51B5"},secondary:{main:"#F6AE2D"}}}),i6=()=>{const{changePassword:e}=p.useContext(vr),[t,n]=p.useState(""),[r,o]=p.useState(""),[i,a]=p.useState(!1),[s,l]=p.useState(""),[c,d]=p.useState("success"),{userId:f}=Ms(),m=async w=>{w.preventDefault();const y=await e(f,t,r);l(y.message),d(y.success?"success":"error"),a(!0)};return u.jsx(lm,{theme:Ey,children:u.jsx(Zw,{component:"main",maxWidth:"xs",sx:{background:"#fff",borderRadius:"8px",boxShadow:"0px 2px 4px rgba(0,0,0,0.2)"},children:u.jsxs(et,{sx:{marginTop:8,display:"flex",flexDirection:"column",alignItems:"center"},children:[u.jsx(Ie,{component:"h1",variant:"h5",children:"Update Password"}),u.jsxs("form",{onSubmit:m,style:{width:"100%",marginTop:Ey.spacing(1)},children:[u.jsx(at,{variant:"outlined",margin:"normal",required:!0,fullWidth:!0,id:"current-password",label:"Current Password",name:"currentPassword",autoComplete:"current-password",type:"password",value:t,onChange:w=>n(w.target.value),InputProps:{startAdornment:u.jsx(g2,{color:"primary",style:{marginRight:"10px"}})}}),u.jsx(at,{variant:"outlined",margin:"normal",required:!0,fullWidth:!0,id:"new-password",label:"New Password",name:"newPassword",autoComplete:"new-password",type:"password",value:r,onChange:w=>o(w.target.value),InputProps:{startAdornment:u.jsx(m2,{color:"secondary",style:{marginRight:"10px"}})}}),u.jsx(Rt,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:3,mb:2},children:"Update Password"})]}),u.jsx(yo,{open:i,autoHideDuration:6e3,onClose:()=>a(!1),children:u.jsx(xr,{onClose:()=>a(!1),severity:c,sx:{width:"100%"},children:s})})]})})})};var Xm={},a6=Te;Object.defineProperty(Xm,"__esModule",{value:!0});var v2=Xm.default=void 0,s6=a6(Me()),l6=u;v2=Xm.default=(0,s6.default)((0,l6.jsx)("path",{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 4-8 5-8-5V6l8 5 8-5z"}),"Email");var Qm={},c6=Te;Object.defineProperty(Qm,"__esModule",{value:!0});var y2=Qm.default=void 0,u6=c6(Me()),d6=u;y2=Qm.default=(0,u6.default)((0,d6.jsx)("path",{d:"M12 6c1.11 0 2-.9 2-2 0-.38-.1-.73-.29-1.03L12 0l-1.71 2.97c-.19.3-.29.65-.29 1.03 0 1.1.9 2 2 2m4.6 9.99-1.07-1.07-1.08 1.07c-1.3 1.3-3.58 1.31-4.89 0l-1.07-1.07-1.09 1.07C6.75 16.64 5.88 17 4.96 17c-.73 0-1.4-.23-1.96-.61V21c0 .55.45 1 1 1h16c.55 0 1-.45 1-1v-4.61c-.56.38-1.23.61-1.96.61-.92 0-1.79-.36-2.44-1.01M18 9h-5V7h-2v2H6c-1.66 0-3 1.34-3 3v1.54c0 1.08.88 1.96 1.96 1.96.52 0 1.02-.2 1.38-.57l2.14-2.13 2.13 2.13c.74.74 2.03.74 2.77 0l2.14-2.13 2.13 2.13c.37.37.86.57 1.38.57 1.08 0 1.96-.88 1.96-1.96V12C21 10.34 19.66 9 18 9"}),"Cake");var Jm={},f6=Te;Object.defineProperty(Jm,"__esModule",{value:!0});var x2=Jm.default=void 0,p6=f6(Me()),h6=u;x2=Jm.default=(0,p6.default)((0,h6.jsx)("path",{d:"M5.5 22v-7.5H4V9c0-1.1.9-2 2-2h3c1.1 0 2 .9 2 2v5.5H9.5V22zM18 22v-6h3l-2.54-7.63C18.18 7.55 17.42 7 16.56 7h-.12c-.86 0-1.63.55-1.9 1.37L12 16h3v6zM7.5 6c1.11 0 2-.89 2-2s-.89-2-2-2-2 .89-2 2 .89 2 2 2m9 0c1.11 0 2-.89 2-2s-.89-2-2-2-2 .89-2 2 .89 2 2 2"}),"Wc");var Zm={},m6=Te;Object.defineProperty(Zm,"__esModule",{value:!0});var b2=Zm.default=void 0,g6=m6(Me()),v6=u;b2=Zm.default=(0,g6.default)((0,v6.jsx)("path",{d:"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"}),"Home");var eg={},y6=Te;Object.defineProperty(eg,"__esModule",{value:!0});var w2=eg.default=void 0,x6=y6(Me()),b6=u;w2=eg.default=(0,x6.default)((0,b6.jsx)("path",{d:"M20 6h-4V4c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2m-6 0h-4V4h4z"}),"Work");var tg={},w6=Te;Object.defineProperty(tg,"__esModule",{value:!0});var ng=tg.default=void 0,S6=w6(Me()),C6=u;ng=tg.default=(0,S6.default)((0,C6.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6m0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20"}),"AccountCircle");var rg={},k6=Te;Object.defineProperty(rg,"__esModule",{value:!0});var S2=rg.default=void 0,R6=k6(Me()),P6=u;S2=rg.default=(0,R6.default)((0,P6.jsx)("path",{d:"M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8z"}),"Update");const E6=ie(f2)({background:"#fff",borderRadius:"8px",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",margin:"20px 0",maxWidth:"100%",overflow:"hidden"}),Ty=ie(ql)({fontSize:"1rem",fontWeight:"bold",color:"#3F51B5",marginRight:"4px",marginLeft:"4px",flex:1,maxWidth:"none","&.Mui-selected":{color:"#F6AE2D",background:"#e0e0e0"},"&:hover":{background:"#f4f4f4",transition:"background-color 0.3s"},"@media (max-width: 720px)":{padding:"6px 12px",fontSize:"0.8rem"}}),T6=zs({palette:{primary:{main:"#3F51B5"},secondary:{main:"#F6AE2D"},background:{default:"#e0e0e0"}},typography:{fontFamily:'"Open Sans", "Helvetica", "Arial", sans-serif',button:{textTransform:"none",fontWeight:"bold"}},components:{MuiButton:{styleOverrides:{root:{boxShadow:"none",borderRadius:8,"&:hover":{boxShadow:"0px 2px 4px rgba(0,0,0,0.2)"}}}},MuiPaper:{styleOverrides:{root:{padding:"20px",borderRadius:"10px",boxShadow:"0px 4px 12px rgba(0,0,0,0.1)"}}}}}),$6=ie(En)(({theme:e})=>({marginTop:e.spacing(2),padding:e.spacing(2),display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(2),boxShadow:e.shadows[3]}));function j6(){const{userId:e}=Ms(),[t,n]=p.useState({username:"",name:"",email:"",age:"",gender:"",placeOfResidence:"",fieldOfWork:"",mental_health_concerns:[]}),[r,o]=p.useState(0),i=(g,h)=>{o(h)},[a,s]=p.useState(""),[l,c]=p.useState(!1),[d,f]=p.useState("info");p.useEffect(()=>{if(!e){console.error("User ID is undefined");return}(async()=>{try{const h=await Oe.get(`/api/user/profile/${e}`);console.log("Fetched data:",h.data);const b={username:h.data.username||"",name:h.data.name||"",email:h.data.email||"",age:h.data.age||"",gender:h.data.gender||"",placeOfResidence:h.data.placeOfResidence||"Not specified",fieldOfWork:h.data.fieldOfWork||"Not specified",mental_health_concerns:h.data.mental_health_concerns||[]};console.log("Formatted data:",b),n(b)}catch{s("Failed to fetch user data"),f("error"),c(!0)}})()},[e]);const m=[{label:"Stress from Job Search",value:"job_search"},{label:"Stress from Classwork",value:"classwork"},{label:"Social Anxiety",value:"social_anxiety"},{label:"Impostor Syndrome",value:"impostor_syndrome"},{label:"Career Drift",value:"career_drift"}];console.log("current mental health concerns: ",t.mental_health_concerns);const w=g=>{const{name:h,checked:b}=g.target;n(C=>{const R=b?[...C.mental_health_concerns,h]:C.mental_health_concerns.filter(E=>E!==h);return{...C,mental_health_concerns:R}})},y=g=>{const{name:h,value:b}=g.target;n(C=>({...C,[h]:b}))},x=async g=>{g.preventDefault();try{await Oe.patch(`/api/user/profile/${e}`,t),s("Profile updated successfully!"),f("success")}catch{s("Failed to update profile"),f("error")}c(!0)},k=()=>{c(!1)};return u.jsxs(lm,{theme:T6,children:[u.jsx(Rm,{}),u.jsxs(Zw,{component:"main",maxWidth:"md",children:[u.jsxs(E6,{value:r,onChange:i,centered:!0,children:[u.jsx(Ty,{label:"Profile"}),u.jsx(Ty,{label:"Update Password"})]}),r===0&&u.jsxs($6,{component:"form",onSubmit:x,sx:{maxHeight:"81vh",overflow:"auto"},children:[u.jsxs(Ie,{variant:"h5",style:{fontWeight:700},children:[u.jsx(ng,{style:{marginRight:"10px"}})," ",t.username]}),u.jsx(at,{fullWidth:!0,label:"Name",variant:"outlined",name:"name",value:t.name||"",onChange:y,InputProps:{startAdornment:u.jsx(lt,{position:"start",children:u.jsx(cd,{})})}}),u.jsx(at,{fullWidth:!0,label:"Email",variant:"outlined",name:"email",value:t.email||"",onChange:y,InputProps:{startAdornment:u.jsx(lt,{position:"start",children:u.jsx(v2,{})})}}),u.jsx(at,{fullWidth:!0,label:"Age",variant:"outlined",name:"age",type:"number",value:t.age||"",onChange:y,InputProps:{startAdornment:u.jsx(lt,{children:u.jsx(y2,{})})}}),u.jsxs(sd,{fullWidth:!0,children:[u.jsx(ld,{children:"Gender"}),u.jsxs(Vs,{name:"gender",value:t.gender||"",label:"Gender",onChange:y,startAdornment:u.jsx(lt,{children:u.jsx(x2,{})}),children:[u.jsx(Zn,{value:"male",children:"Male"}),u.jsx(Zn,{value:"female",children:"Female"}),u.jsx(Zn,{value:"other",children:"Other"})]})]}),u.jsx(at,{fullWidth:!0,label:"Place of Residence",variant:"outlined",name:"placeOfResidence",value:t.placeOfResidence||"",onChange:y,InputProps:{startAdornment:u.jsx(lt,{children:u.jsx(b2,{})})}}),u.jsx(at,{fullWidth:!0,label:"Field of Work",variant:"outlined",name:"fieldOfWork",value:t.fieldOfWork||"",onChange:y,InputProps:{startAdornment:u.jsx(lt,{position:"start",children:u.jsx(w2,{})})}}),u.jsx(o2,{children:m.map((g,h)=>(console.log(`Is "${g.label}" checked?`,t.mental_health_concerns.includes(g.value)),u.jsx(Tm,{control:u.jsx(km,{checked:t.mental_health_concerns.includes(g.value),onChange:w,name:g.value}),label:u.jsxs(et,{display:"flex",alignItems:"center",children:[g.label,u.jsx(Ln,{title:u.jsx(Ie,{variant:"body2",children:M6(g.value)}),arrow:!0,placement:"right",children:u.jsx(Gm,{color:"action",style:{marginLeft:4,fontSize:20}})})]})},h)))}),u.jsxs(Rt,{type:"submit",color:"primary",variant:"contained",children:[u.jsx(S2,{style:{marginRight:"10px"}}),"Update Profile"]})]}),r===1&&u.jsx(i6,{userId:e}),u.jsx(yo,{open:l,autoHideDuration:6e3,onClose:k,children:u.jsx(xr,{onClose:k,severity:d,sx:{width:"100%"},children:a})})]})]})}function M6(e){switch(e){case"job_search":return"Feelings of stress stemming from the job search process.";case"classwork":return"Stress related to managing coursework and academic responsibilities.";case"social_anxiety":return"Anxiety experienced during social interactions or in anticipation of social interactions.";case"impostor_syndrome":return"Persistent doubt concerning one's abilities or accomplishments coupled with a fear of being exposed as a fraud.";case"career_drift":return"Stress from uncertainty or dissatisfaction with one's career path or progress.";default:return"No description available."}}var og={},O6=Te;Object.defineProperty(og,"__esModule",{value:!0});var C2=og.default=void 0,I6=O6(Me()),$y=u;C2=og.default=(0,I6.default)([(0,$y.jsx)("path",{d:"M22 9 12 2 2 9h9v13h2V9z"},"0"),(0,$y.jsx)("path",{d:"m4.14 12-1.96.37.82 4.37V22h2l.02-4H7v4h2v-6H4.9zm14.96 4H15v6h2v-4h1.98l.02 4h2v-5.26l.82-4.37-1.96-.37z"},"1")],"Deck");var ig={},_6=Te;Object.defineProperty(ig,"__esModule",{value:!0});var k2=ig.default=void 0,L6=_6(Me()),A6=u;k2=ig.default=(0,L6.default)((0,A6.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5m-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11m3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5"}),"InsertEmoticon");var ag={},N6=Te;Object.defineProperty(ag,"__esModule",{value:!0});var sg=ag.default=void 0,D6=N6(Me()),z6=u;sg=ag.default=(0,D6.default)((0,z6.jsx)("path",{d:"M19 5v14H5V5zm1.1-2H3.9c-.5 0-.9.4-.9.9v16.2c0 .4.4.9.9.9h16.2c.4 0 .9-.5.9-.9V3.9c0-.5-.5-.9-.9-.9M11 7h6v2h-6zm0 4h6v2h-6zm0 4h6v2h-6zM7 7h2v2H7zm0 4h2v2H7zm0 4h2v2H7z"}),"ListAlt");var lg={},B6=Te;Object.defineProperty(lg,"__esModule",{value:!0});var R2=lg.default=void 0,F6=B6(Me()),U6=u;R2=lg.default=(0,F6.default)((0,U6.jsx)("path",{d:"M10.09 15.59 11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2"}),"ExitToApp");var cg={},W6=Te;Object.defineProperty(cg,"__esModule",{value:!0});var P2=cg.default=void 0,V6=W6(Me()),H6=u;P2=cg.default=(0,V6.default)((0,H6.jsx)("path",{d:"M16.53 11.06 15.47 10l-4.88 4.88-2.12-2.12-1.06 1.06L10.59 17zM19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 16H5V8h14z"}),"EventAvailable");var ug={},q6=Te;Object.defineProperty(ug,"__esModule",{value:!0});var E2=ug.default=void 0,G6=q6(Me()),jy=u;E2=ug.default=(0,G6.default)([(0,jy.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),(0,jy.jsx)("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"Schedule");var dg={},K6=Te;Object.defineProperty(dg,"__esModule",{value:!0});var T2=dg.default=void 0,Y6=K6(Me()),X6=u;T2=dg.default=(0,Y6.default)((0,X6.jsx)("path",{d:"m22.69 18.37 1.14-1-1-1.73-1.45.49c-.32-.27-.68-.48-1.08-.63L20 14h-2l-.3 1.49c-.4.15-.76.36-1.08.63l-1.45-.49-1 1.73 1.14 1c-.08.5-.08.76 0 1.26l-1.14 1 1 1.73 1.45-.49c.32.27.68.48 1.08.63L18 24h2l.3-1.49c.4-.15.76-.36 1.08-.63l1.45.49 1-1.73-1.14-1c.08-.51.08-.77 0-1.27M19 21c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2M11 7v5.41l2.36 2.36 1.04-1.79-1.4-1.39V7zm10 5c0-4.97-4.03-9-9-9-2.83 0-5.35 1.32-7 3.36V4H3v6h6V8H6.26C7.53 6.19 9.63 5 12 5c3.86 0 7 3.14 7 7zm-10.14 6.91c-2.99-.49-5.35-2.9-5.78-5.91H3.06c.5 4.5 4.31 8 8.94 8h.07z"}),"ManageHistory");const My=230;function Q6(){const{logout:e,user:t}=p.useContext(vr),n=ho(),r=i=>n.pathname===i,o=[{text:"Mind Chat",icon:u.jsx(C2,{}),path:"/"},...t!=null&&t.userId?[{text:"Track Your Vibes",icon:u.jsx(k2,{}),path:"/user/mood_logging"},{text:"Mood Logs",icon:u.jsx(sg,{}),path:"/user/mood_logs"},{text:"Schedule Check-In",icon:u.jsx(E2,{}),path:"/user/check_in"},{text:"Check-In Reporting",icon:u.jsx(P2,{}),path:`/user/check_ins/${t==null?void 0:t.userId}`},{text:"Chat Log Manager",icon:u.jsx(T2,{}),path:"/user/chat_log_Manager"}]:[]];return u.jsx(UI,{sx:{width:My,flexShrink:0,mt:8,"& .MuiDrawer-paper":{width:My,boxSizing:"border-box",position:"relative",height:"91vh",top:0,overflowX:"hidden",borderRadius:2,boxShadow:1}},variant:"permanent",anchor:"left",children:u.jsxs(Ws,{children:[o.map(i=>u.jsx(VP,{to:i.path,style:{textDecoration:"none",color:"inherit"},children:u.jsxs(_c,{button:!0,sx:{backgroundColor:r(i.path)?"rgba(25, 118, 210, 0.5)":"inherit","&:hover":{bgcolor:"grey.200"}},children:[u.jsx(dy,{children:i.icon}),u.jsx(ws,{primary:i.text})]})},i.text)),u.jsxs(_c,{button:!0,onClick:e,children:[u.jsx(dy,{children:u.jsx(R2,{})}),u.jsx(ws,{primary:"Logout"})]})]})})}var fg={},J6=Te;Object.defineProperty(fg,"__esModule",{value:!0});var $2=fg.default=void 0,Z6=J6(Me()),eD=u;$2=fg.default=(0,Z6.default)((0,eD.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");var pg={},tD=Te;Object.defineProperty(pg,"__esModule",{value:!0});var j2=pg.default=void 0,nD=tD(Me()),rD=u;j2=pg.default=(0,nD.default)((0,rD.jsx)("path",{d:"M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2m6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1z"}),"Notifications");var hg={},oD=Te;Object.defineProperty(hg,"__esModule",{value:!0});var M2=hg.default=void 0,iD=oD(Me()),aD=u;M2=hg.default=(0,iD.default)((0,aD.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12z"}),"Cancel");function sD({toggleSidebar:e}){const{incrementNotificationCount:t,notifications:n,addNotification:r,removeNotification:o}=p.useContext(vr),i=qo(),{user:a}=p.useContext(vr),[s,l]=p.useState(null),c=localStorage.getItem("token"),d=a==null?void 0:a.userId;console.log("User ID:",d),p.useEffect(()=>{d?f():console.error("No user ID available from URL parameters.")},[d]);const f=async()=>{if(!d){console.error("User ID is missing in context");return}try{const k=(await Oe.get(`/api/check-in/missed?user_id=${d}`,{headers:{Authorization:`Bearer ${c}`}})).data;console.log("Missed check-ins:",k),k.length>0?k.forEach(g=>{r({title:`Missed Check-in on ${new Date(g.check_in_time).toLocaleString()}`,message:"Please complete your check-in."})}):r({title:"You have no missed check-ins.",message:""})}catch(x){console.error("Failed to fetch missed check-ins:",x),r({title:"Failed to fetch missed check-ins. Please check the console for more details.",message:""})}},m=x=>{l(x.currentTarget)},w=x=>{l(null),o(x)},y=()=>{a&&a.userId?i(`/user/profile/${a.userId}`):console.error("User ID not found")};return p.useEffect(()=>{const x=k=>{k.data&&k.data.msg==="updateCount"&&(console.log("Received message from service worker:",k.data),r({title:k.data.title,message:k.data.body}),t())};return navigator.serviceWorker.addEventListener("message",x),()=>{navigator.serviceWorker.removeEventListener("message",x)}},[]),u.jsx(kj,{position:"fixed",sx:{zIndex:x=>x.zIndex.drawer+1},children:u.jsxs(BA,{children:[u.jsx(lt,{onClick:e,color:"inherit",edge:"start",sx:{marginRight:2},children:u.jsx($2,{})}),u.jsx(Ie,{variant:"h6",noWrap:!0,component:"div",sx:{flexGrow:1},children:"Dashboard"}),(a==null?void 0:a.userId)&&u.jsx(lt,{color:"inherit",onClick:m,children:u.jsx(i3,{badgeContent:n.length,color:"secondary",children:u.jsx(j2,{})})}),u.jsx(l2,{anchorEl:s,open:!!s,onClose:()=>w(null),children:n.map((x,k)=>u.jsx(Zn,{onClick:()=>w(k),sx:{whiteSpace:"normal",maxWidth:350,padding:1},children:u.jsxs(id,{elevation:2,sx:{display:"flex",alignItems:"center",width:"100%"},children:[u.jsx(M2,{color:"error"}),u.jsxs(Cm,{sx:{flex:"1 1 auto"},children:[u.jsx(Ie,{variant:"subtitle1",sx:{fontWeight:"bold"},children:x.title}),u.jsx(Ie,{variant:"body2",color:"text.secondary",children:x.message})]})]})},k))}),(a==null?void 0:a.userId)&&u.jsx(lt,{color:"inherit",onClick:y,children:u.jsx(ng,{})})]})})}var mg={},lD=Te;Object.defineProperty(mg,"__esModule",{value:!0});var O2=mg.default=void 0,cD=lD(Me()),uD=u;O2=mg.default=(0,cD.default)((0,uD.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M17 13l-5 5-5-5h3V9h4v4z"}),"CloudDownload");var gg={},dD=Te;Object.defineProperty(gg,"__esModule",{value:!0});var _p=gg.default=void 0,fD=dD(Me()),pD=u;_p=gg.default=(0,fD.default)((0,pD.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zm2.46-7.12 1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"}),"DeleteForever");var vg={},hD=Te;Object.defineProperty(vg,"__esModule",{value:!0});var I2=vg.default=void 0,mD=hD(Me()),gD=u;I2=vg.default=(0,mD.default)((0,gD.jsx)("path",{d:"M9 11H7v2h2zm4 0h-2v2h2zm4 0h-2v2h2zm2-7h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 16H5V9h14z"}),"DateRange");const vD=ie(En)(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadius,boxShadow:1,maxWidth:"100%",margin:"auto",marginTop:e.spacing(2),backgroundColor:"#fff",overflow:"auto"})),Cl=ie(Rt)(({theme:e})=>({margin:e.spacing(0),paddingLeft:e.spacing(1),paddingRight:e.spacing(3)}));function yD(){const[e,t]=nn.useState(!1),[n,r]=p.useState(!1),[o,i]=nn.useState(""),[a,s]=nn.useState("info"),[l,c]=p.useState(!1),[d,f]=p.useState(""),[m,w]=p.useState(""),[y,x]=p.useState(!1),k=(R,E)=>{E!=="clickaway"&&t(!1)},g=()=>{r(!1)},h=R=>{x(R),r(!0)},b=async(R=!1)=>{var E,P;c(!0);try{const M=R?"/api/user/download_chat_logs/range":"/api/user/download_chat_logs",D=R?{params:{start_date:d,end_date:m}}:{},O=await Oe.get(M,{...D,headers:{Authorization:`Bearer ${localStorage.getItem("token")}`},responseType:"blob"}),F=window.URL.createObjectURL(new Blob([O.data])),V=document.createElement("a");V.href=F,V.setAttribute("download",R?"chat_logs_range.csv":"chat_logs.csv"),document.body.appendChild(V),V.click(),i("Chat logs downloaded successfully."),s("success")}catch(M){i(`Failed to download chat logs: ${((P=(E=M.response)==null?void 0:E.data)==null?void 0:P.error)||M.message}`),s("error")}finally{c(!1)}t(!0)},C=async()=>{var R,E;r(!1),c(!0);try{const P=y?"/api/user/delete_chat_logs/range":"/api/user/delete_chat_logs",M=y?{params:{start_date:d,end_date:m}}:{},D=await Oe.delete(P,{...M,headers:{Authorization:`Bearer ${localStorage.getItem("token")}`}});i(D.data.message),s("success")}catch(P){i(`Failed to delete chat logs: ${((E=(R=P.response)==null?void 0:R.data)==null?void 0:E.error)||P.message}`),s("error")}finally{c(!1)}t(!0)};return u.jsxs(vD,{sx:{height:"91vh"},children:[u.jsx(Ie,{variant:"h4",gutterBottom:!0,children:"Manage Your Chat Logs"}),u.jsx(Ie,{variant:"body1",paragraph:!0,children:"Manage your chat logs efficiently by downloading or deleting entries for specific dates or entire ranges. Please be cautious as deletion is permanent."}),u.jsxs("div",{style:{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",gap:20},children:[u.jsxs("div",{style:{display:"flex",gap:10,marginBottom:20},children:[u.jsx(at,{label:"Start Date",type:"date",value:d,onChange:R=>f(R.target.value),InputLabelProps:{shrink:!0}}),u.jsx(at,{label:"End Date",type:"date",value:m,onChange:R=>w(R.target.value),InputLabelProps:{shrink:!0}})]}),u.jsx(Ie,{variant:"body1",paragraph:!0,children:"Here you can download your chat logs as a CSV file, which includes details like chat IDs, content, type, and additional information for each session."}),u.jsx(Ln,{title:"Download chat logs for selected date range",children:u.jsx(Cl,{variant:"outlined",startIcon:u.jsx(I2,{}),onClick:()=>b(!0),disabled:l||!d||!m,children:l?u.jsx(_n,{size:24,color:"inherit"}):"Download Range"})}),u.jsx(Ln,{title:"Download your chat logs as a CSV file",children:u.jsx(Cl,{variant:"contained",color:"primary",startIcon:u.jsx(O2,{}),onClick:()=>b(!1),disabled:l,children:l?u.jsx(_n,{size:24,color:"inherit"}):"Download Chat Logs"})}),u.jsx(Ie,{variant:"body1",paragraph:!0,children:"If you need to clear your history for privacy or other reasons, you can also permanently delete your chat logs from the server."}),u.jsx(Ln,{title:"Delete chat logs for selected date range",children:u.jsx(Cl,{variant:"outlined",color:"warning",startIcon:u.jsx(_p,{}),onClick:()=>h(!0),disabled:l||!d||!m,children:l?u.jsx(_n,{size:24,color:"inherit"}):"Delete Range"})}),u.jsx(Ln,{title:"Permanently delete all your chat logs",children:u.jsx(Cl,{variant:"contained",color:"secondary",startIcon:u.jsx(_p,{}),onClick:()=>h(!1),disabled:l,children:l?u.jsx(_n,{size:24,color:"inherit"}):"Delete Chat Logs"})}),u.jsx(Ie,{variant:"body1",paragraph:!0,children:"Please use these options carefully as deleting your chat logs is irreversible."})]}),u.jsxs($p,{open:n,onClose:g,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[u.jsx(Op,{id:"alert-dialog-title",children:"Confirm Deletion"}),u.jsx(Mp,{children:u.jsx(t2,{id:"alert-dialog-description",children:"Are you sure you want to delete these chat logs? This action cannot be undone."})}),u.jsxs(jp,{children:[u.jsx(Rt,{onClick:g,color:"primary",children:"Cancel"}),u.jsx(Rt,{onClick:()=>C(),color:"secondary",autoFocus:!0,children:"Confirm"})]})]}),u.jsx(yo,{open:e,autoHideDuration:6e3,onClose:k,children:u.jsx(xr,{onClose:k,severity:a,sx:{width:"100%"},children:o})})]})}const Oy=()=>{const{user:e,voiceEnabled:t,setVoiceEnabled:n}=p.useContext(vr),r=e==null?void 0:e.userId,[o,i]=p.useState(0),[a,s]=p.useState(0),[l,c]=p.useState(""),[d,f]=p.useState([]),[m,w]=p.useState(!1),[y,x]=p.useState(null),k=p.useRef([]),[g,h]=p.useState(!1),[b,C]=p.useState(!1),[R,E]=p.useState(""),[P,M]=p.useState("info"),[D,O]=p.useState(null),F=T=>{T.preventDefault(),n(!t)},V=T=>{if(!t||T===D){O(null),window.speechSynthesis.cancel();return}const L=window.speechSynthesis,_=new SpeechSynthesisUtterance(T),N=()=>{const H=L.getVoices();console.log(H.map(A=>`${A.name} - ${A.lang} - ${A.gender}`));const j=H.find(A=>A.name.includes("Microsoft Zira - English (United States)"));j?_.voice=j:console.log("No female voice found"),_.onend=()=>{O(null)},O(T),L.speak(_)};L.getVoices().length===0?L.onvoiceschanged=N:N()},U=(T,L)=>{L!=="clickaway"&&C(!1)},q=p.useCallback(async()=>{if(o!==null){h(!0);try{const T=await fetch(`/api/ai/mental_health/finalize/${r}/${o}`,{method:"POST",headers:{"Content-Type":"application/json"}}),L=await T.json();T.ok?(E("Chat finalized successfully"),M("success"),i(null),s(0),f([])):(E("Failed to finalize chat"),M("error"))}catch{E("Error finalizing chat"),M("error")}finally{h(!1),C(!0)}}},[r,o]),ee=p.useCallback(async()=>{if(l.trim()){console.log(o),h(!0);try{const T=JSON.stringify({prompt:l,turn_id:a}),L=await fetch(`/api/ai/mental_health/${r}/${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:T}),_=await L.json();console.log(_),L.ok?(f(N=>[...N,{message:l,sender:"user"},{message:_,sender:"agent"}]),s(N=>N+1),c("")):(console.error("Failed to send message:",_),E(_.error||"An error occurred while sending the message."),M("error"),C(!0))}catch(T){console.error("Failed to send message:",T),E("Network or server error occurred."),M("error"),C(!0)}finally{h(!1)}}},[l,r,o,a]),J=()=>MediaRecorder.isTypeSupported("audio/webm; codecs=opus")?"audio/webm; codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"audio/wav",re=()=>{navigator.mediaDevices.getUserMedia({audio:{sampleRate:44100,channelCount:1,volume:1,echoCancellation:!0}}).then(T=>{k.current=[];const L=J();let _=new MediaRecorder(T,{mimeType:L});_.ondataavailable=N=>{k.current.push(N.data)},_.start(),x(_),w(!0)}).catch(T=>{console.error("Error accessing microphone:",T)})},I=()=>{y&&(y.stream.getTracks().forEach(T=>T.stop()),y.onstop=()=>{const T=y.mimeType,L=new Blob(k.current,{type:T});B(L),w(!1),x(null)},y.stop())},B=T=>{if(T.size===0){console.error("Audio Blob is empty");return}const L=new FormData;L.append("audio",T),h(!0),Oe.post("/api/ai/mental_health/voice-to-text",L,{headers:{"Content-Type":"multipart/form-data"}}).then(_=>{const{message:N}=_.data;c(N),ee()}).catch(_=>{console.error("Error uploading audio:",_)}).finally(()=>{h(!1)})},$=p.useCallback(T=>{const L=T.target.value;L.split(/\s+/).length>200?(c(N=>N.split(/\s+/).slice(0,200).join(" ")),E("Word limit reached. Only 200 words allowed."),M("warning"),C(!0)):c(L)},[]),v=T=>T===D?u.jsx(Cs,{}):u.jsx(Ss,{});return u.jsxs(u.Fragment,{children:[u.jsx("style",{children:` @keyframes blink { 0%, 100% { opacity: 0; } 50% { opacity: 1; } @@ -486,4 +486,4 @@ Error generating stack: `+i.message+` font-size: 0.8rem; /* Smaller font size */ } } - `}),u.jsxs(et,{sx:{maxWidth:"100%",mx:"auto",my:2,display:"flex",flexDirection:"column",height:"91vh",borderRadius:2,boxShadow:1},children:[u.jsxs(id,{sx:{display:"flex",flexDirection:"column",height:"100%",borderRadius:2,boxShadow:3},children:[u.jsxs(Cm,{sx:{flexGrow:1,overflow:"auto",padding:3,position:"relative"},children:[u.jsxs(et,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",position:"relative",marginBottom:"5px"},children:[u.jsx(Ln,{title:"Toggle voice responses",children:u.jsx(lt,{color:"inherit",onClick:F,sx:{padding:0},children:u.jsx(d2,{checked:t,onChange:T=>n(T.target.checked),icon:u.jsx(Cs,{}),checkedIcon:u.jsx(Ss,{}),inputProps:{"aria-label":"Voice response toggle"},color:"default",sx:{height:42,"& .MuiSwitch-switchBase":{padding:"9px"},"& .MuiSwitch-switchBase.Mui-checked":{color:"white",transform:"translateX(16px)","& + .MuiSwitch-track":{backgroundColor:"primary.main"}}}})})}),u.jsx(Ln,{title:"Start a new chat",placement:"top",arrow:!0,children:u.jsx(lt,{"aria-label":"new chat",color:"primary",onClick:q,disabled:g,sx:{"&:hover":{backgroundColor:"primary.main",color:"common.white"}},children:u.jsx(Um,{})})})]}),u.jsx(Wi,{sx:{marginBottom:"10px"}}),d.length===0&&u.jsxs(et,{sx:{display:"flex",marginBottom:2,marginTop:3},children:[u.jsx(Er,{src:Pi,sx:{width:44,height:44,marginRight:2},alt:"Aria"}),u.jsx(Ie,{variant:"h4",component:"h1",gutterBottom:!0,children:"Welcome to Mental Health Companion"})]}),u.jsx(Ws,{sx:{maxHeight:"100%",overflow:"auto"},children:d.map((T,L)=>u.jsx(_c,{sx:{display:"flex",flexDirection:"column",alignItems:T.sender==="user"?"flex-end":"flex-start",borderRadius:2,mb:.5,p:1,border:"none","&:before":{display:"none"},"&:after":{display:"none"}},children:u.jsxs(et,{sx:{display:"flex",alignItems:"center",color:T.sender==="user"?"common.white":"text.primary",borderRadius:"16px"},children:[T.sender==="agent"&&u.jsx(Er,{src:Pi,sx:{width:36,height:36,mr:1},alt:"Aria"}),u.jsx(ws,{primary:u.jsxs(et,{sx:{display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"nowrap"},children:[T.message,t&&T.sender==="agent"&&u.jsx(lt,{onClick:()=>V(T.message),size:"small",sx:{ml:1},children:v(T.message)})]}),primaryTypographyProps:{sx:{color:T.sender==="user"?"common.white":"text.primary",bgcolor:T.sender==="user"?"primary.main":"grey.200",borderRadius:"16px",px:2,py:1,display:"inline-block"}}}),T.sender==="user"&&u.jsx(Er,{sx:{width:36,height:36,ml:1},children:u.jsx(cd,{})})]})},L))})]}),u.jsx(Wi,{}),u.jsxs(et,{sx:{p:2,pb:1,display:"flex",alignItems:"center",bgcolor:"background.paper"},children:[u.jsx(at,{fullWidth:!0,variant:"outlined",placeholder:"Type your message here...",value:l,onChange:$,disabled:g,sx:{mr:1,flexGrow:1},InputProps:{endAdornment:u.jsx(Ic,{position:"end",children:u.jsxs(lt,{onClick:m?I:re,color:"primary.main","aria-label":m?"Stop recording":"Start recording",size:"large",edge:"end",disabled:g,children:[m?u.jsx(Nm,{size:"small"}):u.jsx(Lm,{size:"small"}),m&&u.jsx(_n,{size:30,sx:{color:"primary.main",position:"absolute",zIndex:1}})]})})}}),g?u.jsx(_n,{size:24}):u.jsx(Rt,{variant:"contained",color:"primary",onClick:ee,disabled:g||!l.trim(),endIcon:u.jsx(oa,{}),children:"Send"})]})]}),u.jsx(yo,{open:b,autoHideDuration:6e3,onClose:U,children:u.jsx(xr,{elevation:6,variant:"filled",onClose:U,severity:P,children:R})})]})]})};var yg={},xD=Te;Object.defineProperty(yg,"__esModule",{value:!0});var _2=yg.default=void 0,bD=xD(Me()),wD=u;_2=yg.default=(0,bD.default)((0,wD.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5m-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11m3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5"}),"Mood");function SD(){const[e,t]=p.useState(""),[n,r]=p.useState(""),[o,i]=p.useState(""),a=async()=>{const s=localStorage.getItem("token");if(!e||!n){i("Both mood and activities are required.");return}if(!s){i("You are not logged in.");return}try{const l=await Oe.post("/api/user/log_mood",{mood:e,activities:n},{headers:{Authorization:`Bearer ${s}`}});i(l.data.message)}catch(l){i(l.response.data.error)}};return u.jsxs("div",{className:"mood-logging-container",children:[u.jsxs("h1",{children:[u.jsx(_2,{fontSize:"large"})," Track Your Vibes "]}),u.jsxs("div",{className:"mood-logging",children:[u.jsxs("div",{className:"input-group",children:[u.jsx("label",{htmlFor:"mood-input",children:"Mood:"}),u.jsx("input",{id:"mood-input",type:"text",value:e,onChange:s=>t(s.target.value),placeholder:"Enter your current mood"}),u.jsx("label",{htmlFor:"activities-input",children:"Activities:"}),u.jsx("input",{id:"activities-input",type:"text",value:n,onChange:s=>r(s.target.value),placeholder:"What are you doing?"})]}),u.jsx(Rt,{variant:"contained",className:"submit-button",onClick:a,startIcon:u.jsx(oa,{}),children:"Log Mood"}),o&&u.jsx("div",{className:"message",children:o})]})]})}function CD(){const[e,t]=p.useState([]),[n,r]=p.useState("");p.useEffect(()=>{(async()=>{const a=localStorage.getItem("token");if(!a){r("You are not logged in.");return}try{const s=await Oe.get("/api/user/get_mood_logs",{headers:{Authorization:`Bearer ${a}`}});console.log("Received data:",s.data),t(s.data.mood_logs||[])}catch(s){r(s.response.data.error)}})()},[]);const o=i=>{const a={year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"};try{const s=i.$date;return new Date(s).toLocaleDateString("en-US",a)}catch(s){return console.error("Date parsing error:",s),"Invalid Date"}};return u.jsxs("div",{className:"mood-logs",children:[u.jsxs("h2",{children:[u.jsx(sg,{className:"icon-large"}),"Your Mood Journey"]}),n?u.jsx("div",{className:"error",children:n}):u.jsx("ul",{children:e.map((i,a)=>u.jsxs("li",{children:[u.jsxs("div",{children:[u.jsx("strong",{children:"Mood:"})," ",i.mood]}),u.jsxs("div",{children:[u.jsx("strong",{children:"Activities:"})," ",i.activities]}),u.jsxs("div",{children:[u.jsx("strong",{children:"Timestamp:"})," ",o(i.timestamp)]})]},a))})]})}function kD(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}const L2=6e4,A2=36e5;function lf(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}function RD(e,t){const n=kD(e);if(isNaN(n.getTime()))throw new RangeError("Invalid time value");const r=(t==null?void 0:t.format)??"extended";let o="";const i=r==="extended"?"-":"";{const a=lf(n.getDate(),2),s=lf(n.getMonth()+1,2);o=`${lf(n.getFullYear(),4)}${i}${s}${i}${a}`}return o}function PD(e,t){const r=jD(e);let o;if(r.date){const l=MD(r.date,2);o=OD(l.restDateString,l.year)}if(!o||isNaN(o.getTime()))return new Date(NaN);const i=o.getTime();let a=0,s;if(r.time&&(a=ID(r.time),isNaN(a)))return new Date(NaN);if(r.timezone){if(s=_D(r.timezone),isNaN(s))return new Date(NaN)}else{const l=new Date(i+a),c=new Date(0);return c.setFullYear(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()),c.setHours(l.getUTCHours(),l.getUTCMinutes(),l.getUTCSeconds(),l.getUTCMilliseconds()),c}return new Date(i+a+s)}const kl={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ED=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,TD=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,$D=/^([+-])(\d{2})(?::?(\d{2}))?$/;function jD(e){const t={},n=e.split(kl.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],kl.timeZoneDelimiter.test(t.date)&&(t.date=e.split(kl.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const o=kl.timezone.exec(r);o?(t.time=r.replace(o[1],""),t.timezone=o[1]):t.time=r}return t}function MD(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const o=r[1]?parseInt(r[1]):null,i=r[2]?parseInt(r[2]):null;return{year:i===null?o:i*100,restDateString:e.slice((r[1]||r[2]).length)}}function OD(e,t){if(t===null)return new Date(NaN);const n=e.match(ED);if(!n)return new Date(NaN);const r=!!n[4],o=Ra(n[1]),i=Ra(n[2])-1,a=Ra(n[3]),s=Ra(n[4]),l=Ra(n[5])-1;if(r)return zD(t,s,l)?LD(t,s,l):new Date(NaN);{const c=new Date(0);return!ND(t,i,a)||!DD(t,o)?new Date(NaN):(c.setUTCFullYear(t,i,Math.max(o,a)),c)}}function Ra(e){return e?parseInt(e):1}function ID(e){const t=e.match(TD);if(!t)return NaN;const n=cf(t[1]),r=cf(t[2]),o=cf(t[3]);return BD(n,r,o)?n*A2+r*L2+o*1e3:NaN}function cf(e){return e&&parseFloat(e.replace(",","."))||0}function _D(e){if(e==="Z")return 0;const t=e.match($D);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),o=t[3]&&parseInt(t[3])||0;return FD(r,o)?n*(r*A2+o*L2):NaN}function LD(e,t,n){const r=new Date(0);r.setUTCFullYear(e,0,4);const o=r.getUTCDay()||7,i=(t-1)*7+n+1-o;return r.setUTCDate(r.getUTCDate()+i),r}const AD=[31,null,31,30,31,30,31,31,30,31,30,31];function N2(e){return e%400===0||e%4===0&&e%100!==0}function ND(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(AD[t]||(N2(e)?29:28))}function DD(e,t){return t>=1&&t<=(N2(e)?366:365)}function zD(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function BD(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function FD(e,t){return t>=0&&t<=59}function Lp({userId:e,update:t}){const[n,r]=p.useState(""),[o,i]=p.useState("daily"),[a,s]=p.useState(!1),{checkInId:l}=Ms(),[c,d]=p.useState(!1),[f,m]=p.useState({open:!1,message:"",severity:"info"}),w=localStorage.getItem("token");p.useEffect(()=>{t&&l&&(d(!0),Oe.get(`/api/check-in/${l}`,{headers:{Authorization:`Bearer ${w}`}}).then(k=>{const g=k.data;console.log("Fetched check-in data:",g);const h=RD(PD(g.check_in_time),{representation:"date"});r(h.slice(0,16)),i(g.frequency),s(g.notify),d(!1)}).catch(k=>{console.error("Failed to fetch check-in details:",k),d(!1)}))},[t,l]);const y=async k=>{var P,M,D;if(k.preventDefault(),new Date(n)<=new Date){m({open:!0,message:"Cannot schedule check-in in the past. Please choose a future time.",severity:"error"});return}const b=t?`/api/check-in/${l}`:"/api/check-in/schedule",C={headers:{Authorization:`Bearer ${w}`,"Content-Type":"application/json"}};console.log("URL:",b);const R=t?"patch":"post",E={user_id:e,check_in_time:n,frequency:o,notify:a};console.log("Submitting:",E);try{const O=await Oe[R](b,E,C);console.log("Success:",O.data.message),m({open:!0,message:O.data.message,severity:"success"})}catch(O){console.error("Error:",((P=O.response)==null?void 0:P.data)||O);const F=((D=(M=O.response)==null?void 0:M.data)==null?void 0:D.error)||"An unexpected error occurred";m({open:!0,message:F,severity:"error"})}},x=(k,g)=>{g!=="clickaway"&&m({...f,open:!1})};return c?u.jsx(Ie,{children:"Loading..."}):u.jsxs(et,{component:"form",onSubmit:y,noValidate:!0,sx:{mt:4,padding:3,borderRadius:2,boxShadow:3},children:[u.jsx(at,{id:"datetime-local",label:"Check-in Time",type:"datetime-local",fullWidth:!0,value:n,onChange:k=>r(k.target.value),sx:{marginBottom:3},InputLabelProps:{shrink:!0},required:!0,helperText:"Select the date and time for your check-in."}),u.jsxs(sd,{fullWidth:!0,sx:{marginBottom:3},children:[u.jsx(ld,{id:"frequency-label",children:"Frequency"}),u.jsxs(Vs,{labelId:"frequency-label",id:"frequency",value:o,label:"Frequency",onChange:k=>i(k.target.value),children:[u.jsx(Zn,{value:"daily",children:"Daily"}),u.jsx(Zn,{value:"weekly",children:"Weekly"}),u.jsx(Zn,{value:"monthly",children:"Monthly"})]}),u.jsx(Ln,{title:"Choose how often you want the check-ins to occur",children:u.jsx("i",{className:"fas fa-info-circle"})})]}),u.jsx(Tm,{control:u.jsx(km,{checked:a,onChange:k=>s(k.target.checked),color:"primary"}),label:"Notify me",sx:{marginBottom:2}}),u.jsx(Rt,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2,padding:"10px 0"},children:t?"Update Check-In":"Schedule Check-In"}),u.jsx(yo,{open:f.open,autoHideDuration:6e3,onClose:x,children:u.jsx(xr,{onClose:x,severity:f.severity,children:f.message})})]})}Lp.propTypes={userId:Vd.string.isRequired,checkInId:Vd.string,update:Vd.bool.isRequired};var xg={},UD=Te;Object.defineProperty(xg,"__esModule",{value:!0});var D2=xg.default=void 0,WD=UD(Me()),Iy=u;D2=xg.default=(0,WD.default)([(0,Iy.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),(0,Iy.jsx)("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"AccessTime");var bg={},VD=Te;Object.defineProperty(bg,"__esModule",{value:!0});var z2=bg.default=void 0,HD=VD(Me()),qD=u;z2=bg.default=(0,HD.default)((0,qD.jsx)("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2z"}),"Repeat");var wg={},GD=Te;Object.defineProperty(wg,"__esModule",{value:!0});var B2=wg.default=void 0,KD=GD(Me()),YD=u;B2=wg.default=(0,KD.default)((0,YD.jsx)("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreVert");var Sg={},XD=Te;Object.defineProperty(Sg,"__esModule",{value:!0});var F2=Sg.default=void 0,QD=XD(Me()),JD=u;F2=Sg.default=(0,QD.default)((0,JD.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"}),"Delete");var Cg={},ZD=Te;Object.defineProperty(Cg,"__esModule",{value:!0});var U2=Cg.default=void 0,ez=ZD(Me()),tz=u;U2=Cg.default=(0,ez.default)((0,tz.jsx)("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Edit");const nz=ie(id)(({theme:e})=>({marginBottom:e.spacing(2),padding:e.spacing(2),display:"flex",alignItems:"center",justifyContent:"space-between",transition:"transform 0.1s ease-in-out","&:hover":{transform:"scale(1.01)",boxShadow:e.shadows[3]}})),rz=nn.forwardRef(function(t,n){return u.jsx(xr,{elevation:6,ref:n,variant:"filled",...t})});function oz(){const{userId:e}=Ms(),t=qo(),[n,r]=p.useState([]),[o,i]=p.useState(null),[a,s]=p.useState(!1),[l,c]=p.useState(!1),[d,f]=p.useState(!1),[m,w]=p.useState(""),[y,x]=p.useState(!1),[k,g]=p.useState(""),[h,b]=p.useState("info"),C=localStorage.getItem("token");p.useEffect(()=>{R()},[e]);const R=async()=>{if(!e){w("User not logged in");return}if(!C){w("No token found, please log in again");return}f(!0);try{const V=await Oe.get(`/api/check-in/all?user_id=${e}`,{headers:{Authorization:`Bearer ${C}`}});if(console.log("API Response:",V.data),Array.isArray(V.data)&&V.data.every(U=>U._id&&U._id.$oid&&U.check_in_time&&U.check_in_time.$date)){const U=V.data.map(q=>({...q,_id:q._id.$oid,check_in_time:new Date(q.check_in_time.$date).toLocaleString()}));r(U)}else console.error("Data received is not in expected array format:",V.data),w("Unexpected data format");f(!1)}catch(V){console.error("Error during fetch:",V),w(V.message),f(!1)}},E=V=>{const U=n.find(q=>q._id===V);U&&(i(U),console.log("Selected check-in for details or update:",U),s(!0))},P=()=>{s(!1),c(!1)},M=async()=>{if(o){try{await Oe.delete(`/api/check-in/${o._id}`,{headers:{Authorization:`Bearer ${C}`}}),g("Check-in deleted successfully"),b("success"),R(),P()}catch{g("Failed to delete check-in"),b("error")}x(!0)}},D=()=>{t(`/user/check_in/${o._id}`),console.log("Redirecting to update check-in form",o._id)},O=(V,U)=>{U!=="clickaway"&&x(!1)},F=()=>{c(!0)};return e?d?u.jsx(Ie,{variant:"h6",mt:"2",children:"Loading..."}):u.jsxs(et,{sx:{margin:3,maxWidth:600,mx:"auto",maxHeight:"91vh",overflow:"auto"},children:[u.jsx(Ie,{variant:"h4",gutterBottom:!0,children:"Track Your Commitments"}),u.jsx(Wi,{sx:{mb:2}}),n.length>0?u.jsx(Ws,{children:n.map(V=>u.jsxs(nz,{children:[u.jsx(Z_,{children:u.jsx(Er,{sx:{bgcolor:"primary.main"},children:u.jsx(D2,{})})}),u.jsx(ws,{primary:`Check-In: ${V.check_in_time}`,secondary:u.jsx(EO,{label:V.frequency,icon:u.jsx(z2,{}),size:"small"})}),u.jsx(Ln,{title:"More options",children:u.jsx(lt,{onClick:()=>E(V._id),children:u.jsx(B2,{})})})]},V._id))}):u.jsx(Ie,{variant:"h6",sx:{mb:2,mt:2,color:"error.main",fontWeight:"medium",textAlign:"center",padding:2,borderRadius:1,backgroundColor:"background.paper",boxShadow:2},children:"No check-ins found."}),u.jsxs($p,{open:a,onClose:P,children:[u.jsx(Op,{children:"Check-In Details"}),u.jsx(Mp,{children:u.jsxs(Ie,{component:"div",children:[u.jsxs(Ie,{variant:"body1",children:[u.jsx("strong",{children:"Time:"})," ",o==null?void 0:o.check_in_time]}),u.jsxs(Ie,{variant:"body1",children:[u.jsx("strong",{children:"Frequency:"})," ",o==null?void 0:o.frequency]}),u.jsxs(Ie,{variant:"body1",children:[u.jsx("strong",{children:"Status:"})," ",o==null?void 0:o.status]}),u.jsxs(Ie,{variant:"body1",children:[u.jsx("strong",{children:"Notify:"})," ",o!=null&&o.notify?"Yes":"No"]})]})}),u.jsxs(jp,{children:[u.jsx(Rt,{onClick:D,startIcon:u.jsx(U2,{}),children:"Update"}),u.jsx(Rt,{onClick:F,startIcon:u.jsx(F2,{}),color:"error",children:"Delete"}),u.jsx(Rt,{onClick:P,children:"Close"})]})]}),u.jsxs($p,{open:l,onClose:P,children:[u.jsx(Op,{children:"Confirm Deletion"}),u.jsx(Mp,{children:u.jsx(t2,{children:"Are you sure you want to delete this check-in? This action cannot be undone."})}),u.jsxs(jp,{children:[u.jsx(Rt,{onClick:M,color:"error",children:"Delete"}),u.jsx(Rt,{onClick:P,children:"Cancel"})]})]}),u.jsx(yo,{open:y,autoHideDuration:6e3,onClose:O,children:u.jsx(rz,{onClose:O,severity:h,children:k})})]}):u.jsx(Ie,{variant:"h6",mt:"2",children:"Please log in to see your check-ins."})}const wr=({children:e})=>{const t=localStorage.getItem("token");return console.log("isAuthenticated:",t),t?e:u.jsx(MP,{to:"/auth",replace:!0})};var kg={},iz=Te;Object.defineProperty(kg,"__esModule",{value:!0});var W2=kg.default=void 0,az=iz(Me()),sz=u;W2=kg.default=(0,az.default)((0,sz.jsx)("path",{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 14H4V8l8 5 8-5zm-8-7L4 6h16z"}),"MailOutline");function lz(){const[e,t]=p.useState(""),[n,r]=p.useState(""),[o,i]=p.useState(!1),[a,s]=p.useState(!1),l=async c=>{var d,f;c.preventDefault(),s(!0);try{const m=await Oe.post("/api/user/request_reset",{email:e});r(m.data.message),i(!1)}catch(m){r(((f=(d=m.response)==null?void 0:d.data)==null?void 0:f.message)||"Failed to send reset link. Please try again."),i(!0)}s(!1)};return u.jsx(et,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",sx:{background:"linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)","& .MuiPaper-root":{background:"#fff",padding:"30px",width:"400px",textAlign:"center"}},children:u.jsxs(En,{elevation:3,style:{padding:"30px",width:"400px",textAlign:"center"},children:[u.jsx(Ie,{variant:"h5",component:"h1",marginBottom:"20px",children:"Reset Your Password"}),u.jsxs("form",{onSubmit:l,children:[u.jsx(at,{label:"Email Address",type:"email",value:e,onChange:c=>t(c.target.value),variant:"outlined",fullWidth:!0,required:!0,margin:"normal",InputProps:{endAdornment:u.jsx(W2,{})}}),u.jsx(Rt,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,disabled:a,endIcon:a?null:u.jsx(oa,{}),children:a?u.jsx(_n,{size:24}):"Send Reset Link"})]}),n&&u.jsx(xr,{severity:o?"error":"success",sx:{maxWidth:"325px",mt:2},children:n})]})})}var Rg={},cz=Te;Object.defineProperty(Rg,"__esModule",{value:!0});var Ap=Rg.default=void 0,uz=cz(Me()),dz=u;Ap=Rg.default=(0,uz.default)((0,dz.jsx)("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility");var Pg={},fz=Te;Object.defineProperty(Pg,"__esModule",{value:!0});var V2=Pg.default=void 0,pz=fz(Me()),hz=u;V2=Pg.default=(0,pz.default)((0,hz.jsx)("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l4 4 4-4H6c0-3.86 3.14-7 7-7s7 3.14 7 7-3.14 7-7 7c-1.9 0-3.62-.76-4.88-1.99L6.7 18.42C8.32 20.01 10.55 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9m2 8v-1c0-1.1-.9-2-2-2s-2 .9-2 2v1c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1m-1 0h-2v-1c0-.55.45-1 1-1s1 .45 1 1z"}),"LockReset");function mz(){const e=qo(),{token:t}=Ms(),[n,r]=p.useState(""),[o,i]=p.useState(""),[a,s]=p.useState(!1),[l,c]=p.useState(""),[d,f]=p.useState(!1),m=async y=>{if(y.preventDefault(),n!==o){c("Passwords do not match."),f(!0);return}try{const x=await Oe.post(`/api/user/reset_password/${t}`,{password:n});c(x.data.message),f(!1),setTimeout(()=>e("/auth"),2e3)}catch(x){c(x.response.data.error),f(!0)}},w=()=>{s(!a)};return u.jsx(et,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",sx:{background:"linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)","& .MuiPaper-root":{padding:"40px",width:"400px",textAlign:"center",marginTop:"20px",borderRadius:"10px"}},children:u.jsxs(En,{elevation:6,children:[u.jsxs(Ie,{variant:"h5",component:"h1",marginBottom:"2",children:["Reset Your Password ",u.jsx(V2,{})]}),u.jsxs("form",{onSubmit:m,children:[u.jsx(at,{label:"New Password",type:a?"text":"password",value:n,onChange:y=>r(y.target.value),variant:"outlined",fullWidth:!0,required:!0,margin:"normal",InputProps:{endAdornment:u.jsx(Ic,{position:"end",children:u.jsx(lt,{"aria-label":"toggle password visibility",onClick:w,children:a?u.jsx(Ap,{}):u.jsx(Ac,{})})})}}),u.jsx(at,{label:"Confirm New Password",type:a?"text":"password",value:o,onChange:y=>i(y.target.value),variant:"outlined",fullWidth:!0,required:!0,margin:"normal",InputProps:{endAdornment:u.jsx(Ic,{position:"end",children:u.jsx(lt,{"aria-label":"toggle password visibility",onClick:w,children:a?u.jsx(Ap,{}):u.jsx(Ac,{})})})}}),u.jsx(Rt,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,sx:{mt:2},endIcon:u.jsx(oa,{}),children:"Reset Password"})]}),l&&u.jsx(xr,{severity:d?"error":"success",sx:{mt:2,maxWidth:"325px"},children:l})]})})}function gz(){const{user:e}=p.useContext(vr);return p.useEffect(()=>{document.body.style.backgroundColor="#f5f5f5"},[]),u.jsx(vz,{children:u.jsxs(IP,{children:[u.jsx(mn,{path:"/",element:u.jsx(wr,{children:e!=null&&e.userId?u.jsx(NN,{}):u.jsx(Oy,{})})}),u.jsx(mn,{path:"/chat",element:u.jsx(wr,{children:u.jsx(Oy,{})})}),u.jsx(mn,{path:"/reset_password/:token",element:u.jsx(mz,{})}),u.jsx(mn,{path:"/request_reset",element:u.jsx(lz,{})}),u.jsx(mn,{path:"/auth",element:u.jsx(QN,{})}),u.jsx(mn,{path:"/user/profile/:userId",element:u.jsx(wr,{children:u.jsx(j6,{})})}),u.jsx(mn,{path:"/user/mood_logging",element:u.jsx(wr,{children:u.jsx(SD,{})})}),u.jsx(mn,{path:"/user/mood_logs",element:u.jsx(wr,{children:u.jsx(CD,{})})}),u.jsx(mn,{path:"/user/check_in",element:u.jsx(wr,{children:u.jsx(Lp,{userId:e==null?void 0:e.userId,checkInId:"",update:!1})})}),u.jsx(mn,{path:"/user/check_in/:checkInId",element:u.jsx(wr,{children:u.jsx(Lp,{userId:e==null?void 0:e.userId,update:!0})})}),u.jsx(mn,{path:"/user/chat_log_Manager",element:u.jsx(wr,{children:u.jsx(yD,{})})}),u.jsx(mn,{path:"/user/check_ins/:userId",element:u.jsx(wr,{children:u.jsx(oz,{})})})]})})}function vz({children:e}){p.useContext(vr);const t=ho(),r=!["/auth","/request_reset",new RegExp("^/reset_password/[^/]+$")].some(l=>typeof l=="string"?l===t.pathname:l.test(t.pathname)),o=r?6:0,[i,a]=p.useState(!0),s=()=>{a(!i)};return u.jsxs(et,{sx:{display:"flex",maxHeight:"100vh"},children:[u.jsx(Rm,{}),r&&u.jsx(sD,{toggleSidebar:s}),r&&i&&u.jsx(Q6,{}),u.jsx(et,{component:"main",sx:{flexGrow:1,p:o},children:e})]})}function yz(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new Uint8Array(r.length);for(let i=0;i{if(t!=="granted")throw new Error("Permission not granted for Notification");return e.pushManager.getSubscription()}).then(function(t){return t||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:yz(bz)})}).then(function(t){console.log("Subscription:",t);const n={p256dh:btoa(String.fromCharCode.apply(null,new Uint8Array(t.getKey("p256dh")))),auth:btoa(String.fromCharCode.apply(null,new Uint8Array(t.getKey("auth"))))};if(console.log("Subscription keys:",n),!n.p256dh||!n.auth)throw console.error("Subscription object:",t),new Error("Subscription keys are missing");const r={endpoint:t.endpoint,keys:n},o=xz();if(!o)throw new Error("No token found");return fetch("/api/subscribe",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(r)})}).then(t=>t.json()).then(t=>console.log("Subscription response:",t)).catch(t=>console.error("Subscription failed:",t))}).catch(function(e){console.error("Service Worker registration failed:",e)})});uf.createRoot(document.getElementById("root")).render(u.jsx(FP,{children:u.jsx(KP,{children:u.jsx(gz,{})})})); + `}),u.jsxs(et,{sx:{maxWidth:"100%",mx:"auto",my:2,display:"flex",flexDirection:"column",height:"91vh",borderRadius:2,boxShadow:1},children:[u.jsxs(id,{sx:{display:"flex",flexDirection:"column",height:"100%",borderRadius:2,boxShadow:3},children:[u.jsxs(Cm,{sx:{flexGrow:1,overflow:"auto",padding:3,position:"relative"},children:[u.jsxs(et,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",position:"relative",marginBottom:"5px"},children:[u.jsx(Ln,{title:"Toggle voice responses",children:u.jsx(lt,{color:"inherit",onClick:F,sx:{padding:0},children:u.jsx(d2,{checked:t,onChange:T=>n(T.target.checked),icon:u.jsx(Cs,{}),checkedIcon:u.jsx(Ss,{}),inputProps:{"aria-label":"Voice response toggle"},color:"default",sx:{height:42,"& .MuiSwitch-switchBase":{padding:"9px"},"& .MuiSwitch-switchBase.Mui-checked":{color:"white",transform:"translateX(16px)","& + .MuiSwitch-track":{backgroundColor:"primary.main"}}}})})}),u.jsx(Ln,{title:"Start a new chat",placement:"top",arrow:!0,children:u.jsx(lt,{"aria-label":"new chat",color:"primary",onClick:q,disabled:g,sx:{"&:hover":{backgroundColor:"primary.main",color:"common.white"}},children:u.jsx(Um,{})})})]}),u.jsx(Wi,{sx:{marginBottom:"10px"}}),d.length===0&&u.jsxs(et,{sx:{display:"flex",marginBottom:2,marginTop:3},children:[u.jsx(Er,{src:Pi,sx:{width:44,height:44,marginRight:2},alt:"Aria"}),u.jsx(Ie,{variant:"h4",component:"h1",gutterBottom:!0,children:"Welcome to Your Mental Health Companion"})]}),u.jsx(Ws,{sx:{maxHeight:"100%",overflow:"auto"},children:d.map((T,L)=>u.jsx(_c,{sx:{display:"flex",flexDirection:"column",alignItems:T.sender==="user"?"flex-end":"flex-start",borderRadius:2,mb:.5,p:1,border:"none","&:before":{display:"none"},"&:after":{display:"none"}},children:u.jsxs(et,{sx:{display:"flex",alignItems:"center",color:T.sender==="user"?"common.white":"text.primary",borderRadius:"16px"},children:[T.sender==="agent"&&u.jsx(Er,{src:Pi,sx:{width:36,height:36,mr:1},alt:"Aria"}),u.jsx(ws,{primary:u.jsxs(et,{sx:{display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"nowrap"},children:[T.message,t&&T.sender==="agent"&&u.jsx(lt,{onClick:()=>V(T.message),size:"small",sx:{ml:1},children:v(T.message)})]}),primaryTypographyProps:{sx:{color:T.sender==="user"?"common.white":"text.primary",bgcolor:T.sender==="user"?"primary.main":"grey.200",borderRadius:"16px",px:2,py:1,display:"inline-block"}}}),T.sender==="user"&&u.jsx(Er,{sx:{width:36,height:36,ml:1},children:u.jsx(cd,{})})]})},L))})]}),u.jsx(Wi,{}),u.jsxs(et,{sx:{p:2,pb:1,display:"flex",alignItems:"center",bgcolor:"background.paper"},children:[u.jsx(at,{fullWidth:!0,variant:"outlined",placeholder:"Type your message here...",value:l,onChange:$,disabled:g,sx:{mr:1,flexGrow:1},InputProps:{endAdornment:u.jsx(Ic,{position:"end",children:u.jsxs(lt,{onClick:m?I:re,color:"primary.main","aria-label":m?"Stop recording":"Start recording",size:"large",edge:"end",disabled:g,children:[m?u.jsx(Nm,{size:"small"}):u.jsx(Lm,{size:"small"}),m&&u.jsx(_n,{size:30,sx:{color:"primary.main",position:"absolute",zIndex:1}})]})})}}),g?u.jsx(_n,{size:24}):u.jsx(Rt,{variant:"contained",color:"primary",onClick:ee,disabled:g||!l.trim(),endIcon:u.jsx(oa,{}),children:"Send"})]})]}),u.jsx(yo,{open:b,autoHideDuration:6e3,onClose:U,children:u.jsx(xr,{elevation:6,variant:"filled",onClose:U,severity:P,children:R})})]})]})};var yg={},xD=Te;Object.defineProperty(yg,"__esModule",{value:!0});var _2=yg.default=void 0,bD=xD(Me()),wD=u;_2=yg.default=(0,bD.default)((0,wD.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5m-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11m3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5"}),"Mood");function SD(){const[e,t]=p.useState(""),[n,r]=p.useState(""),[o,i]=p.useState(""),a=async()=>{const s=localStorage.getItem("token");if(!e||!n){i("Both mood and activities are required.");return}if(!s){i("You are not logged in.");return}try{const l=await Oe.post("/api/user/log_mood",{mood:e,activities:n},{headers:{Authorization:`Bearer ${s}`}});i(l.data.message)}catch(l){i(l.response.data.error)}};return u.jsxs("div",{className:"mood-logging-container",children:[u.jsxs("h1",{children:[u.jsx(_2,{fontSize:"large"})," Track Your Vibes "]}),u.jsxs("div",{className:"mood-logging",children:[u.jsxs("div",{className:"input-group",children:[u.jsx("label",{htmlFor:"mood-input",children:"Mood:"}),u.jsx("input",{id:"mood-input",type:"text",value:e,onChange:s=>t(s.target.value),placeholder:"Enter your current mood"}),u.jsx("label",{htmlFor:"activities-input",children:"Activities:"}),u.jsx("input",{id:"activities-input",type:"text",value:n,onChange:s=>r(s.target.value),placeholder:"What are you doing?"})]}),u.jsx(Rt,{variant:"contained",className:"submit-button",onClick:a,startIcon:u.jsx(oa,{}),children:"Log Mood"}),o&&u.jsx("div",{className:"message",children:o})]})]})}function CD(){const[e,t]=p.useState([]),[n,r]=p.useState("");p.useEffect(()=>{(async()=>{const a=localStorage.getItem("token");if(!a){r("You are not logged in.");return}try{const s=await Oe.get("/api/user/get_mood_logs",{headers:{Authorization:`Bearer ${a}`}});console.log("Received data:",s.data),t(s.data.mood_logs||[])}catch(s){r(s.response.data.error)}})()},[]);const o=i=>{const a={year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"};try{const s=i.$date;return new Date(s).toLocaleDateString("en-US",a)}catch(s){return console.error("Date parsing error:",s),"Invalid Date"}};return u.jsxs("div",{className:"mood-logs",children:[u.jsxs("h2",{children:[u.jsx(sg,{className:"icon-large"}),"Your Mood Journey"]}),n?u.jsx("div",{className:"error",children:n}):u.jsx("ul",{children:e.map((i,a)=>u.jsxs("li",{children:[u.jsxs("div",{children:[u.jsx("strong",{children:"Mood:"})," ",i.mood]}),u.jsxs("div",{children:[u.jsx("strong",{children:"Activities:"})," ",i.activities]}),u.jsxs("div",{children:[u.jsx("strong",{children:"Timestamp:"})," ",o(i.timestamp)]})]},a))})]})}function kD(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}const L2=6e4,A2=36e5;function lf(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}function RD(e,t){const n=kD(e);if(isNaN(n.getTime()))throw new RangeError("Invalid time value");const r=(t==null?void 0:t.format)??"extended";let o="";const i=r==="extended"?"-":"";{const a=lf(n.getDate(),2),s=lf(n.getMonth()+1,2);o=`${lf(n.getFullYear(),4)}${i}${s}${i}${a}`}return o}function PD(e,t){const r=jD(e);let o;if(r.date){const l=MD(r.date,2);o=OD(l.restDateString,l.year)}if(!o||isNaN(o.getTime()))return new Date(NaN);const i=o.getTime();let a=0,s;if(r.time&&(a=ID(r.time),isNaN(a)))return new Date(NaN);if(r.timezone){if(s=_D(r.timezone),isNaN(s))return new Date(NaN)}else{const l=new Date(i+a),c=new Date(0);return c.setFullYear(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()),c.setHours(l.getUTCHours(),l.getUTCMinutes(),l.getUTCSeconds(),l.getUTCMilliseconds()),c}return new Date(i+a+s)}const kl={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ED=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,TD=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,$D=/^([+-])(\d{2})(?::?(\d{2}))?$/;function jD(e){const t={},n=e.split(kl.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],kl.timeZoneDelimiter.test(t.date)&&(t.date=e.split(kl.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const o=kl.timezone.exec(r);o?(t.time=r.replace(o[1],""),t.timezone=o[1]):t.time=r}return t}function MD(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const o=r[1]?parseInt(r[1]):null,i=r[2]?parseInt(r[2]):null;return{year:i===null?o:i*100,restDateString:e.slice((r[1]||r[2]).length)}}function OD(e,t){if(t===null)return new Date(NaN);const n=e.match(ED);if(!n)return new Date(NaN);const r=!!n[4],o=Ra(n[1]),i=Ra(n[2])-1,a=Ra(n[3]),s=Ra(n[4]),l=Ra(n[5])-1;if(r)return zD(t,s,l)?LD(t,s,l):new Date(NaN);{const c=new Date(0);return!ND(t,i,a)||!DD(t,o)?new Date(NaN):(c.setUTCFullYear(t,i,Math.max(o,a)),c)}}function Ra(e){return e?parseInt(e):1}function ID(e){const t=e.match(TD);if(!t)return NaN;const n=cf(t[1]),r=cf(t[2]),o=cf(t[3]);return BD(n,r,o)?n*A2+r*L2+o*1e3:NaN}function cf(e){return e&&parseFloat(e.replace(",","."))||0}function _D(e){if(e==="Z")return 0;const t=e.match($D);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),o=t[3]&&parseInt(t[3])||0;return FD(r,o)?n*(r*A2+o*L2):NaN}function LD(e,t,n){const r=new Date(0);r.setUTCFullYear(e,0,4);const o=r.getUTCDay()||7,i=(t-1)*7+n+1-o;return r.setUTCDate(r.getUTCDate()+i),r}const AD=[31,null,31,30,31,30,31,31,30,31,30,31];function N2(e){return e%400===0||e%4===0&&e%100!==0}function ND(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(AD[t]||(N2(e)?29:28))}function DD(e,t){return t>=1&&t<=(N2(e)?366:365)}function zD(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function BD(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function FD(e,t){return t>=0&&t<=59}function Lp({userId:e,update:t}){const[n,r]=p.useState(""),[o,i]=p.useState("daily"),[a,s]=p.useState(!1),{checkInId:l}=Ms(),[c,d]=p.useState(!1),[f,m]=p.useState({open:!1,message:"",severity:"info"}),w=localStorage.getItem("token");p.useEffect(()=>{t&&l&&(d(!0),Oe.get(`/api/check-in/${l}`,{headers:{Authorization:`Bearer ${w}`}}).then(k=>{const g=k.data;console.log("Fetched check-in data:",g);const h=RD(PD(g.check_in_time),{representation:"date"});r(h.slice(0,16)),i(g.frequency),s(g.notify),d(!1)}).catch(k=>{console.error("Failed to fetch check-in details:",k),d(!1)}))},[t,l]);const y=async k=>{var P,M,D;if(k.preventDefault(),new Date(n)<=new Date){m({open:!0,message:"Cannot schedule check-in in the past. Please choose a future time.",severity:"error"});return}const b=t?`/api/check-in/${l}`:"/api/check-in/schedule",C={headers:{Authorization:`Bearer ${w}`,"Content-Type":"application/json"}};console.log("URL:",b);const R=t?"patch":"post",E={user_id:e,check_in_time:n,frequency:o,notify:a};console.log("Submitting:",E);try{const O=await Oe[R](b,E,C);console.log("Success:",O.data.message),m({open:!0,message:O.data.message,severity:"success"})}catch(O){console.error("Error:",((P=O.response)==null?void 0:P.data)||O);const F=((D=(M=O.response)==null?void 0:M.data)==null?void 0:D.error)||"An unexpected error occurred";m({open:!0,message:F,severity:"error"})}},x=(k,g)=>{g!=="clickaway"&&m({...f,open:!1})};return c?u.jsx(Ie,{children:"Loading..."}):u.jsxs(et,{component:"form",onSubmit:y,noValidate:!0,sx:{mt:4,padding:3,borderRadius:2,boxShadow:3},children:[u.jsx(at,{id:"datetime-local",label:"Check-in Time",type:"datetime-local",fullWidth:!0,value:n,onChange:k=>r(k.target.value),sx:{marginBottom:3},InputLabelProps:{shrink:!0},required:!0,helperText:"Select the date and time for your check-in."}),u.jsxs(sd,{fullWidth:!0,sx:{marginBottom:3},children:[u.jsx(ld,{id:"frequency-label",children:"Frequency"}),u.jsxs(Vs,{labelId:"frequency-label",id:"frequency",value:o,label:"Frequency",onChange:k=>i(k.target.value),children:[u.jsx(Zn,{value:"daily",children:"Daily"}),u.jsx(Zn,{value:"weekly",children:"Weekly"}),u.jsx(Zn,{value:"monthly",children:"Monthly"})]}),u.jsx(Ln,{title:"Choose how often you want the check-ins to occur",children:u.jsx("i",{className:"fas fa-info-circle"})})]}),u.jsx(Tm,{control:u.jsx(km,{checked:a,onChange:k=>s(k.target.checked),color:"primary"}),label:"Notify me",sx:{marginBottom:2}}),u.jsx(Rt,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2,padding:"10px 0"},children:t?"Update Check-In":"Schedule Check-In"}),u.jsx(yo,{open:f.open,autoHideDuration:6e3,onClose:x,children:u.jsx(xr,{onClose:x,severity:f.severity,children:f.message})})]})}Lp.propTypes={userId:Vd.string.isRequired,checkInId:Vd.string,update:Vd.bool.isRequired};var xg={},UD=Te;Object.defineProperty(xg,"__esModule",{value:!0});var D2=xg.default=void 0,WD=UD(Me()),Iy=u;D2=xg.default=(0,WD.default)([(0,Iy.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),(0,Iy.jsx)("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"AccessTime");var bg={},VD=Te;Object.defineProperty(bg,"__esModule",{value:!0});var z2=bg.default=void 0,HD=VD(Me()),qD=u;z2=bg.default=(0,HD.default)((0,qD.jsx)("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2z"}),"Repeat");var wg={},GD=Te;Object.defineProperty(wg,"__esModule",{value:!0});var B2=wg.default=void 0,KD=GD(Me()),YD=u;B2=wg.default=(0,KD.default)((0,YD.jsx)("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreVert");var Sg={},XD=Te;Object.defineProperty(Sg,"__esModule",{value:!0});var F2=Sg.default=void 0,QD=XD(Me()),JD=u;F2=Sg.default=(0,QD.default)((0,JD.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"}),"Delete");var Cg={},ZD=Te;Object.defineProperty(Cg,"__esModule",{value:!0});var U2=Cg.default=void 0,ez=ZD(Me()),tz=u;U2=Cg.default=(0,ez.default)((0,tz.jsx)("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Edit");const nz=ie(id)(({theme:e})=>({marginBottom:e.spacing(2),padding:e.spacing(2),display:"flex",alignItems:"center",justifyContent:"space-between",transition:"transform 0.1s ease-in-out","&:hover":{transform:"scale(1.01)",boxShadow:e.shadows[3]}})),rz=nn.forwardRef(function(t,n){return u.jsx(xr,{elevation:6,ref:n,variant:"filled",...t})});function oz(){const{userId:e}=Ms(),t=qo(),[n,r]=p.useState([]),[o,i]=p.useState(null),[a,s]=p.useState(!1),[l,c]=p.useState(!1),[d,f]=p.useState(!1),[m,w]=p.useState(""),[y,x]=p.useState(!1),[k,g]=p.useState(""),[h,b]=p.useState("info"),C=localStorage.getItem("token");p.useEffect(()=>{R()},[e]);const R=async()=>{if(!e){w("User not logged in");return}if(!C){w("No token found, please log in again");return}f(!0);try{const V=await Oe.get(`/api/check-in/all?user_id=${e}`,{headers:{Authorization:`Bearer ${C}`}});if(console.log("API Response:",V.data),Array.isArray(V.data)&&V.data.every(U=>U._id&&U._id.$oid&&U.check_in_time&&U.check_in_time.$date)){const U=V.data.map(q=>({...q,_id:q._id.$oid,check_in_time:new Date(q.check_in_time.$date).toLocaleString()}));r(U)}else console.error("Data received is not in expected array format:",V.data),w("Unexpected data format");f(!1)}catch(V){console.error("Error during fetch:",V),w(V.message),f(!1)}},E=V=>{const U=n.find(q=>q._id===V);U&&(i(U),console.log("Selected check-in for details or update:",U),s(!0))},P=()=>{s(!1),c(!1)},M=async()=>{if(o){try{await Oe.delete(`/api/check-in/${o._id}`,{headers:{Authorization:`Bearer ${C}`}}),g("Check-in deleted successfully"),b("success"),R(),P()}catch{g("Failed to delete check-in"),b("error")}x(!0)}},D=()=>{t(`/user/check_in/${o._id}`),console.log("Redirecting to update check-in form",o._id)},O=(V,U)=>{U!=="clickaway"&&x(!1)},F=()=>{c(!0)};return e?d?u.jsx(Ie,{variant:"h6",mt:"2",children:"Loading..."}):u.jsxs(et,{sx:{margin:3,maxWidth:600,mx:"auto",maxHeight:"91vh",overflow:"auto"},children:[u.jsx(Ie,{variant:"h4",gutterBottom:!0,children:"Track Your Commitments"}),u.jsx(Wi,{sx:{mb:2}}),n.length>0?u.jsx(Ws,{children:n.map(V=>u.jsxs(nz,{children:[u.jsx(Z_,{children:u.jsx(Er,{sx:{bgcolor:"primary.main"},children:u.jsx(D2,{})})}),u.jsx(ws,{primary:`Check-In: ${V.check_in_time}`,secondary:u.jsx(EO,{label:V.frequency,icon:u.jsx(z2,{}),size:"small"})}),u.jsx(Ln,{title:"More options",children:u.jsx(lt,{onClick:()=>E(V._id),children:u.jsx(B2,{})})})]},V._id))}):u.jsx(Ie,{variant:"h6",sx:{mb:2,mt:2,color:"error.main",fontWeight:"medium",textAlign:"center",padding:2,borderRadius:1,backgroundColor:"background.paper",boxShadow:2},children:"No check-ins found."}),u.jsxs($p,{open:a,onClose:P,children:[u.jsx(Op,{children:"Check-In Details"}),u.jsx(Mp,{children:u.jsxs(Ie,{component:"div",children:[u.jsxs(Ie,{variant:"body1",children:[u.jsx("strong",{children:"Time:"})," ",o==null?void 0:o.check_in_time]}),u.jsxs(Ie,{variant:"body1",children:[u.jsx("strong",{children:"Frequency:"})," ",o==null?void 0:o.frequency]}),u.jsxs(Ie,{variant:"body1",children:[u.jsx("strong",{children:"Status:"})," ",o==null?void 0:o.status]}),u.jsxs(Ie,{variant:"body1",children:[u.jsx("strong",{children:"Notify:"})," ",o!=null&&o.notify?"Yes":"No"]})]})}),u.jsxs(jp,{children:[u.jsx(Rt,{onClick:D,startIcon:u.jsx(U2,{}),children:"Update"}),u.jsx(Rt,{onClick:F,startIcon:u.jsx(F2,{}),color:"error",children:"Delete"}),u.jsx(Rt,{onClick:P,children:"Close"})]})]}),u.jsxs($p,{open:l,onClose:P,children:[u.jsx(Op,{children:"Confirm Deletion"}),u.jsx(Mp,{children:u.jsx(t2,{children:"Are you sure you want to delete this check-in? This action cannot be undone."})}),u.jsxs(jp,{children:[u.jsx(Rt,{onClick:M,color:"error",children:"Delete"}),u.jsx(Rt,{onClick:P,children:"Cancel"})]})]}),u.jsx(yo,{open:y,autoHideDuration:6e3,onClose:O,children:u.jsx(rz,{onClose:O,severity:h,children:k})})]}):u.jsx(Ie,{variant:"h6",mt:"2",children:"Please log in to see your check-ins."})}const wr=({children:e})=>{const t=localStorage.getItem("token");return console.log("isAuthenticated:",t),t?e:u.jsx(MP,{to:"/auth",replace:!0})};var kg={},iz=Te;Object.defineProperty(kg,"__esModule",{value:!0});var W2=kg.default=void 0,az=iz(Me()),sz=u;W2=kg.default=(0,az.default)((0,sz.jsx)("path",{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 14H4V8l8 5 8-5zm-8-7L4 6h16z"}),"MailOutline");function lz(){const[e,t]=p.useState(""),[n,r]=p.useState(""),[o,i]=p.useState(!1),[a,s]=p.useState(!1),l=async c=>{var d,f;c.preventDefault(),s(!0);try{const m=await Oe.post("/api/user/request_reset",{email:e});r(m.data.message),i(!1)}catch(m){r(((f=(d=m.response)==null?void 0:d.data)==null?void 0:f.message)||"Failed to send reset link. Please try again."),i(!0)}s(!1)};return u.jsx(et,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",sx:{background:"linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)","& .MuiPaper-root":{background:"#fff",padding:"30px",width:"400px",textAlign:"center"}},children:u.jsxs(En,{elevation:3,style:{padding:"30px",width:"400px",textAlign:"center"},children:[u.jsx(Ie,{variant:"h5",component:"h1",marginBottom:"20px",children:"Reset Your Password"}),u.jsxs("form",{onSubmit:l,children:[u.jsx(at,{label:"Email Address",type:"email",value:e,onChange:c=>t(c.target.value),variant:"outlined",fullWidth:!0,required:!0,margin:"normal",InputProps:{endAdornment:u.jsx(W2,{})}}),u.jsx(Rt,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,disabled:a,endIcon:a?null:u.jsx(oa,{}),children:a?u.jsx(_n,{size:24}):"Send Reset Link"})]}),n&&u.jsx(xr,{severity:o?"error":"success",sx:{maxWidth:"325px",mt:2},children:n})]})})}var Rg={},cz=Te;Object.defineProperty(Rg,"__esModule",{value:!0});var Ap=Rg.default=void 0,uz=cz(Me()),dz=u;Ap=Rg.default=(0,uz.default)((0,dz.jsx)("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility");var Pg={},fz=Te;Object.defineProperty(Pg,"__esModule",{value:!0});var V2=Pg.default=void 0,pz=fz(Me()),hz=u;V2=Pg.default=(0,pz.default)((0,hz.jsx)("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l4 4 4-4H6c0-3.86 3.14-7 7-7s7 3.14 7 7-3.14 7-7 7c-1.9 0-3.62-.76-4.88-1.99L6.7 18.42C8.32 20.01 10.55 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9m2 8v-1c0-1.1-.9-2-2-2s-2 .9-2 2v1c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1m-1 0h-2v-1c0-.55.45-1 1-1s1 .45 1 1z"}),"LockReset");function mz(){const e=qo(),{token:t}=Ms(),[n,r]=p.useState(""),[o,i]=p.useState(""),[a,s]=p.useState(!1),[l,c]=p.useState(""),[d,f]=p.useState(!1),m=async y=>{if(y.preventDefault(),n!==o){c("Passwords do not match."),f(!0);return}try{const x=await Oe.post(`/api/user/reset_password/${t}`,{password:n});c(x.data.message),f(!1),setTimeout(()=>e("/auth"),2e3)}catch(x){c(x.response.data.error),f(!0)}},w=()=>{s(!a)};return u.jsx(et,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",sx:{background:"linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)","& .MuiPaper-root":{padding:"40px",width:"400px",textAlign:"center",marginTop:"20px",borderRadius:"10px"}},children:u.jsxs(En,{elevation:6,children:[u.jsxs(Ie,{variant:"h5",component:"h1",marginBottom:"2",children:["Reset Your Password ",u.jsx(V2,{})]}),u.jsxs("form",{onSubmit:m,children:[u.jsx(at,{label:"New Password",type:a?"text":"password",value:n,onChange:y=>r(y.target.value),variant:"outlined",fullWidth:!0,required:!0,margin:"normal",InputProps:{endAdornment:u.jsx(Ic,{position:"end",children:u.jsx(lt,{"aria-label":"toggle password visibility",onClick:w,children:a?u.jsx(Ap,{}):u.jsx(Ac,{})})})}}),u.jsx(at,{label:"Confirm New Password",type:a?"text":"password",value:o,onChange:y=>i(y.target.value),variant:"outlined",fullWidth:!0,required:!0,margin:"normal",InputProps:{endAdornment:u.jsx(Ic,{position:"end",children:u.jsx(lt,{"aria-label":"toggle password visibility",onClick:w,children:a?u.jsx(Ap,{}):u.jsx(Ac,{})})})}}),u.jsx(Rt,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,sx:{mt:2},endIcon:u.jsx(oa,{}),children:"Reset Password"})]}),l&&u.jsx(xr,{severity:d?"error":"success",sx:{mt:2,maxWidth:"325px"},children:l})]})})}function gz(){const{user:e}=p.useContext(vr);return p.useEffect(()=>{document.body.style.backgroundColor="#f5f5f5"},[]),u.jsx(vz,{children:u.jsxs(IP,{children:[u.jsx(mn,{path:"/",element:u.jsx(wr,{children:e!=null&&e.userId?u.jsx(NN,{}):u.jsx(Oy,{})})}),u.jsx(mn,{path:"/chat",element:u.jsx(wr,{children:u.jsx(Oy,{})})}),u.jsx(mn,{path:"/reset_password/:token",element:u.jsx(mz,{})}),u.jsx(mn,{path:"/request_reset",element:u.jsx(lz,{})}),u.jsx(mn,{path:"/auth",element:u.jsx(QN,{})}),u.jsx(mn,{path:"/user/profile/:userId",element:u.jsx(wr,{children:u.jsx(j6,{})})}),u.jsx(mn,{path:"/user/mood_logging",element:u.jsx(wr,{children:u.jsx(SD,{})})}),u.jsx(mn,{path:"/user/mood_logs",element:u.jsx(wr,{children:u.jsx(CD,{})})}),u.jsx(mn,{path:"/user/check_in",element:u.jsx(wr,{children:u.jsx(Lp,{userId:e==null?void 0:e.userId,checkInId:"",update:!1})})}),u.jsx(mn,{path:"/user/check_in/:checkInId",element:u.jsx(wr,{children:u.jsx(Lp,{userId:e==null?void 0:e.userId,update:!0})})}),u.jsx(mn,{path:"/user/chat_log_Manager",element:u.jsx(wr,{children:u.jsx(yD,{})})}),u.jsx(mn,{path:"/user/check_ins/:userId",element:u.jsx(wr,{children:u.jsx(oz,{})})})]})})}function vz({children:e}){p.useContext(vr);const t=ho(),r=!["/auth","/request_reset",new RegExp("^/reset_password/[^/]+$")].some(l=>typeof l=="string"?l===t.pathname:l.test(t.pathname)),o=r?6:0,[i,a]=p.useState(!0),s=()=>{a(!i)};return u.jsxs(et,{sx:{display:"flex",maxHeight:"100vh"},children:[u.jsx(Rm,{}),r&&u.jsx(sD,{toggleSidebar:s}),r&&i&&u.jsx(Q6,{}),u.jsx(et,{component:"main",sx:{flexGrow:1,p:o},children:e})]})}function yz(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new Uint8Array(r.length);for(let i=0;i{if(t!=="granted")throw new Error("Permission not granted for Notification");return e.pushManager.getSubscription()}).then(function(t){return t||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:yz(bz)})}).then(function(t){console.log("Subscription:",t);const n={p256dh:btoa(String.fromCharCode.apply(null,new Uint8Array(t.getKey("p256dh")))),auth:btoa(String.fromCharCode.apply(null,new Uint8Array(t.getKey("auth"))))};if(console.log("Subscription keys:",n),!n.p256dh||!n.auth)throw console.error("Subscription object:",t),new Error("Subscription keys are missing");const r={endpoint:t.endpoint,keys:n},o=xz();if(!o)throw new Error("No token found");return fetch("/api/subscribe",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(r)})}).then(t=>t.json()).then(t=>console.log("Subscription response:",t)).catch(t=>console.error("Subscription failed:",t))}).catch(function(e){console.error("Service Worker registration failed:",e)})});uf.createRoot(document.getElementById("root")).render(u.jsx(FP,{children:u.jsx(KP,{children:u.jsx(gz,{})})})); diff --git a/client/dist/index.html b/client/dist/index.html index 1f3815ae..56fc83b6 100644 --- a/client/dist/index.html +++ b/client/dist/index.html @@ -7,10 +7,10 @@ - Mental Health App - + Mental Health Companion + diff --git a/client/index.html b/client/index.html index 8bf462a6..d3082522 100644 --- a/client/index.html +++ b/client/index.html @@ -7,9 +7,9 @@ - Mental Health App + Mental Health Companion
diff --git a/client/src/Components/chatComponent.jsx b/client/src/Components/chatComponent.jsx index eee7bb07..707ad669 100644 --- a/client/src/Components/chatComponent.jsx +++ b/client/src/Components/chatComponent.jsx @@ -399,7 +399,7 @@ const sendAudioToServer = (audioBlob) => { - Welcome to Mental Health Companion + Welcome to Your Mental Health Companion )} diff --git a/client/src/Components/chatInterface.jsx b/client/src/Components/chatInterface.jsx index 56c54325..325c10d0 100644 --- a/client/src/Components/chatInterface.jsx +++ b/client/src/Components/chatInterface.jsx @@ -346,7 +346,7 @@ const sendAudioToServer = (audioBlob) => { - Welcome to Mental Health Companion + Welcome to Your Mental Health Companion )}