import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{P as t,f as n,p as r,t as i,u as a,x as o}from"./semantic-ui-react-m4AAKEby.js";import{f as s,m as c}from"./react-vendor-dEvHdx-C.js";var l=({username:e})=>t.get(`/users/notes/${encodeURIComponent(e)}`),u=({username:e,note:n,color:r,icon:i,isHighPriority:a})=>t.post(`/users/notes`,{color:r,icon:i,isHighPriority:a,note:n,username:e}),d=()=>t.get(`/users/notes`),f=e(c()),p=s(),m=[{icon:`circle outline`,text:`None`,value:null},{label:{circular:!0,color:`red`,empty:!0},text:`Red`,value:`red`},{label:{circular:!0,color:`orange`,empty:!0},text:`Orange`,value:`orange`},{label:{circular:!0,color:`yellow`,empty:!0},text:`Yellow`,value:`yellow`},{label:{circular:!0,color:`olive`,empty:!0},text:`Olive`,value:`olive`},{label:{circular:!0,color:`green`,empty:!0},text:`Green`,value:`green`},{label:{circular:!0,color:`teal`,empty:!0},text:`Teal`,value:`teal`},{label:{circular:!0,color:`blue`,empty:!0},text:`Blue`,value:`blue`},{label:{circular:!0,color:`violet`,empty:!0},text:`Violet`,value:`violet`},{label:{circular:!0,color:`purple`,empty:!0},text:`Purple`,value:`purple`},{label:{circular:!0,color:`pink`,empty:!0},text:`Pink`,value:`pink`},{label:{circular:!0,color:`brown`,empty:!0},text:`Brown`,value:`brown`},{label:{circular:!0,color:`grey`,empty:!0},text:`Grey`,value:`grey`},{label:{circular:!0,color:`black`,empty:!0},text:`Black`,value:`black`}],h=({onClose:e,trigger:t,username:s})=>{let[c,d]=(0,f.useState)(!1),[h,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(null),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1);(0,f.useEffect)(()=>{(async()=>{if(!(!s||!c)){S(!0);try{let e=await l({username:s});e.data?(g(e.data.note||``),v(e.data.color||null),b(e.data.isHighPriority||!1)):(g(``),v(null),b(!1))}catch(e){e.response&&e.response.status===404?(g(``),v(null),b(!1)):console.error(`Failed to fetch user note`,e)}finally{S(!1)}}})()},[c,s]);let C=()=>{d(!1),e&&e()};return(0,p.jsxs)(o,{onClose:C,onOpen:()=>d(!0),open:c,size:`tiny`,trigger:t,children:[(0,p.jsxs)(n,{children:[(0,p.jsx)(r,{name:`sticky note outline`}),(0,p.jsxs)(o.Content,{children:[`User Note: `,s]})]}),(0,p.jsx)(o.Content,{children:(0,p.jsxs)(a,{loading:x,children:[(0,p.jsx)(a.Dropdown,{fluid:!0,label:`Color Rating`,onChange:(e,{value:t})=>v(t),options:m,placeholder:`Select Color`,selection:!0,value:_}),(0,p.jsx)(a.TextArea,{label:`Note`,onChange:e=>g(e.target.value),placeholder:`Enter notes about this user...`,rows:5,value:h}),(0,p.jsx)(a.Checkbox,{checked:y,label:`High Priority (Warning)`,onChange:(e,{checked:t})=>b(t)})]})}),(0,p.jsxs)(o.Actions,{children:[(0,p.jsx)(i,{onClick:C,children:`Cancel`}),(0,p.jsx)(i,{disabled:x,onClick:async()=>{S(!0);try{await u({color:_,isHighPriority:y,note:h,username:s}),C()}catch(e){console.error(`Failed to save user note`,e)}finally{S(!1)}},primary:!0,children:`Save`})]})]})};export{d as n,l as r,h as t};