PageSourceSearch

https://www.socialscout.ai/_next/static/immutable/chunks/2k50f4aykw3z7.js

js socialscout.ai collected 2026-10-05 15:08:04 UTC 48,358 bytes, 2 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,946366,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(217255),s=e.i(30678),n=e.i(40280),i=e.i(871544),o=e.i(174080);e.i(427217);var l=e.i(258352),d=e.i(365178),c=e.i(163858),u=e.i(522016),x=e.i(705766);function m(e){return new Date(Date.now()+60*e*1e3)}function p(){let e=new Date;return e.setDate(e.getDate()+1),e.setHours(8,0,0,0),e}let f=[{key:"30m",label:"For 30 minutes",compute:()=>m(30)},{key:"1h",label:"For 1 hour",compute:()=>m(60)},{key:"4h",label:"For 4 hours",compute:()=>m(240)},{key:"until_morning",label:"Until tomorrow at 8am",compute:p}],g=[{key:"none",label:"Don't clear",compute:()=>null},{key:"1h",label:"1 hour",compute:()=>m(60)},{key:"today",label:"Today",compute:function(){let e=new Date;return e.setHours(23,59,0,0),e}},{key:"tomorrow",label:"Tomorrow",compute:p}],h=[{emoji:"🤝",text:"In a meeting"},{emoji:"🎯",text:"Heads down"},{emoji:"🍕",text:"Out to lunch"},{emoji:"🤒",text:"Out sick"},{emoji:"🏝️",text:"On vacation"},{emoji:"🏠",text:"Working remotely"}];function b({user:e,onClose:r,anchorRef:s}){let{status:m,loading:p,setDnd:v,clearDnd:j,setCustomStatus:k,clearCustomStatus:w}=(0,i.default)(),[N,S]=(0,a.useState)(""),[C,z]=(0,a.useState)(""),[E,_]=(0,a.useState)("today"),[I,D]=(0,a.useState)(!1),T=(0,a.useRef)(null),[A,M]=(0,a.useState)({top:0,left:0,openUp:!1}),[L,O]=(0,a.useState)(!1);(0,a.useEffect)(()=>{function e(){M(function(e){if(!e)return{top:0,left:0};let t=e.getBoundingClientRect();window.innerWidth;let a=t.bottom>.6*window.innerHeight,r=a?Math.max(8,t.top-8):t.bottom+8,s=t.right-340;return{top:r,left:s>=8?s:Math.max(8,t.left),openUp:a}}(s?.current))}return O(!0),e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[s]),(0,a.useEffect)(()=>{m?.customStatus&&(S(m.customStatus.emoji||""),z(m.customStatus.text||""))},[m?.customStatus?.text,m?.customStatus?.emoji]),(0,a.useEffect)(()=>{function e(e){!T.current||T.current.contains(e.target)||s?.current?.contains(e.target)||r?.()}function t(e){"Escape"===e.key&&r?.()}return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[r,s]);let P=!!m?.dnd?.until,R=(0,a.useMemo)(()=>(function(e){if(!e)return"";let t=new Date(e),a=new Date;return t.toDateString()===a.toDateString()?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):t.toLocaleString([],{weekday:"short",hour:"numeric",minute:"2-digit"})})(m?.dnd?.until),[m?.dnd?.until]);async function $(e){D(!0);try{await v({until:e.compute(),presetKey:e.key}),x.default.success(`Do Not Disturb on ${e.label.toLowerCase()}`)}catch(e){x.default.error(e.message||"Failed to set DND")}finally{D(!1)}}async function F(){D(!0);try{await j(),x.default.success("Do Not Disturb off")}catch(e){x.default.error(e.message||"Failed to clear DND")}finally{D(!1)}}async function U(){if(!C.trim()&&!N.trim())return void x.default.error("Add an emoji or some text");D(!0);try{let e=g.find(e=>e.key===E);await k({text:C.trim(),emoji:N.trim(),until:e?.compute()||null}),x.default.success("Status updated")}catch(e){x.default.error(e.message||"Failed to save status")}finally{D(!1)}}async function B(){D(!0);try{await w(),S(""),z(""),x.default.success("Status cleared")}catch(e){x.default.error(e.message||"Failed to clear status")}finally{D(!1)}}if(!L||"u"<typeof document)return null;let G=A.openUp?{position:"fixed",top:void 0,bottom:window.innerHeight-A.top,left:A.left,width:340,background:"var(--surface-panel)",border:"1px solid var(--border-default)",backdropFilter:"blur(20px)",boxShadow:"0 14px 40px rgba(0,0,0,0.18)"}:{position:"fixed",top:A.top,left:A.left,width:340,background:"var(--surface-panel)",border:"1px solid var(--border-default)",backdropFilter:"blur(20px)",boxShadow:"0 14px 40px rgba(0,0,0,0.18)"};return(0,o.createPortal)((0,t.jsxs)("div",{ref:T,"data-status-menu":"true",className:"rounded-2xl shadow-2xl z-[100] overflow-hidden",style:G,children:[(0,t.jsxs)("div",{className:"px-4 py-3 border-b border-gray-100 dark:border-zinc-900",children:[(0,t.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:e?.name||"Your status"}),!p&&m&&(0,t.jsx)("div",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mt-1",children:"dnd"===m.status?`On Do Not Disturb until ${R}`:"online"===m.status?"You're online":"away"===m.status?"You're away":"Offline"})]}),(0,t.jsxs)(y,{icon:l.ChatBubbleLeftEllipsisIcon,title:"Custom status",action:m?.customStatus?(0,t.jsx)("button",{type:"button",onClick:B,disabled:I,className:"text-[10px] font-semibold text-gray-400 hover:text-gray-600 dark:text-zinc-500 dark:hover:text-zinc-300",children:"Clear"}):null,children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"text",value:N,onChange:e=>S(e.target.value.slice(0,16)),placeholder:"🙂","aria-label":"Status emoji",className:"w-12 text-center text-lg rounded-lg px-2 py-1.5 outline-none transition-colors",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)"}}),(0,t.jsx)("input",{type:"text",value:C,onChange:e=>z(e.target.value.slice(0,100)),placeholder:"What's your status?","aria-label":"Status text",className:"flex-1 text-[13px] rounded-lg px-3 py-1.5 outline-none transition-colors",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)",color:"var(--text-primary)"}})]}),(0,t.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:h.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{S(e.emoji),z(e.text)},className:"text-[11px] font-medium px-2 py-1 rounded-full transition-colors",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:[(0,t.jsx)("span",{className:"mr-1",children:e.emoji}),e.text]},e.text))}),(0,t.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,t.jsx)("label",{className:"text-[11px] text-gray-400 dark:text-zinc-500",children:"Clear after"}),(0,t.jsx)("select",{value:E,onChange:e=>_(e.target.value),className:"flex-1 text-[11px] rounded-md px-2 py-1 outline-none",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:g.map(e=>(0,t.jsx)("option",{value:e.key,children:e.label},e.key))}),(0,t.jsx)("button",{type:"button",onClick:U,disabled:I,className:"text-[11px] font-semibold px-3 py-1.5 rounded-full text-white transition-all hover:scale-105 disabled:opacity-50",style:{background:"linear-gradient(135deg, #F97316, #EC4899)"},children:"Save"})]})]}),(0,t.jsx)(y,{icon:n.MoonIcon,title:"Do Not Disturb",children:P?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",color:"#ef4444"},children:[(0,t.jsx)(c.CheckCircleIcon,{className:"w-4 h-4"}),(0,t.jsxs)("span",{className:"font-semibold",children:["On until ",R]})]}),(0,t.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-zinc-500",children:"Chat notifications are paused. Task assignments, mentions on tasks, and reminders still come through."}),(0,t.jsx)("button",{type:"button",onClick:F,disabled:I,className:"w-full text-[12px] font-semibold py-2 rounded-lg transition-colors hover:bg-gray-100 dark:hover:bg-zinc-900",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:"Turn off Do Not Disturb"})]}):(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1.5",children:f.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>$(e),disabled:I,className:"text-left text-[12px] font-medium px-3 py-2 rounded-lg transition-colors hover:bg-gray-50 dark:hover:bg-zinc-900",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:e.label},e.key))})}),(0,t.jsxs)(u.default,{href:"/dashboard/user/settings/notifications",onClick:r,className:"flex items-center gap-2 px-4 py-3 border-t border-gray-100 dark:border-zinc-900 text-[12px] font-semibold text-gray-500 dark:text-zinc-400 hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:[(0,t.jsx)(d.
1Cog6ToothIcon,{className:"w-4 h-4"}),"Notification settings"]})]}),document.body)}function y({icon:e,title:a,action:r,children:s}){return(0,t.jsxs)("div",{className:"px-4 py-3 border-b border-gray-100 dark:border-zinc-900 last:border-b-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(e,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500"}),(0,t.jsx)("h4",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:a})]}),r]}),s]})}var v=e.i(923792);e.s(["default",0,function(){let{data:e}=(0,r.useSession)(),{status:o}=(0,i.default)(),[l,d]=(0,a.useState)(!1),c=(0,a.useRef)(null);if(!e?.user?._id)return null;let u=o?.status==="dnd",x=o?.customStatus,m=o?.status||"offline";return(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{ref:c,type:"button",onClick:()=>d(e=>!e),"aria-label":"Set status","aria-expanded":l,title:u?"Do Not Disturb on":x?.text||"Set your status",className:"relative flex items-center justify-center w-9 h-9 rounded-xl transition-all duration-200 hover:bg-white/60 dark:hover:bg-zinc-950/60",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-softer)"},children:[x?.emoji?(0,t.jsx)("span",{className:"text-[16px] leading-none",children:x.emoji}):u?(0,t.jsx)(n.MoonIcon,{className:"w-4 h-4 text-red-500"}):(0,t.jsx)(s.FaceSmileIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"}),(0,t.jsx)(v.default,{status:m,size:9,ringWidth:2,className:"!bottom-[-2px] !right-[-2px]"})]}),l&&(0,t.jsx)(b,{user:e.user,onClose:()=>d(!1),anchorRef:c})]})}],946366)},607271,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(846932),s=e.i(217255),n=e.i(427217),i=e.i(39875),o=e.i(662060),l=e.i(220316),d=e.i(766972),c=e.i(787906),u=e.i(705766),x=e.i(82291);e.s(["default",0,function({onClose:e,onCreated:m}){let{data:p}=(0,s.useSession)(),[f,g]=(0,a.useState)("dm"),[h,b]=(0,a.useState)(!1),[y,v]=(0,a.useState)([]),[j,k]=(0,a.useState)(""),[w,N]=(0,a.useState)([]),[S,C]=(0,a.useState)([]),[z,E]=(0,a.useState)(""),[_,I]=(0,a.useState)(""),D=(0,a.useRef)(null);(0,a.useEffect)(()=>{fetch("/api/agency-team").then(e=>e.ok?e.json():null).then(e=>v((e?.users||[]).filter(e=>e._id?.toString()!==p?.user?._id?.toString()))).catch(()=>{})},[p?.user?._id]),(0,a.useEffect)(()=>{D.current?.focus?.()},[f]);let T=(0,a.useMemo)(()=>{let e=j.trim().toLowerCase();return e?y.filter(t=>(t.name||"").toLowerCase().includes(e)||(t.email||"").toLowerCase().includes(e)):y},[y,j]);function A(e){N(t=>t.find(t=>t._id===e._id)?t.filter(t=>t._id!==e._id):"dm"===f?[e]:[...t,e])}function M(){let e=z.trim().toLowerCase();if(e){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))return void u.default.error("Looks like that's not a valid email");C(t=>t.includes(e)?t:[...t,e]),E("")}}async function L(e){if(e?.preventDefault?.(),!h){if("dm"===f){let e=w[0]||null,t=!e&&S[0]?S[0]:null;if(!e&&!t)return void u.default.error("Pick someone or enter an email");b(!0);try{let a=await fetch("/api/conversations/find-or-create-dm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?{otherUserId:e._id}:{otherEmail:t})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error||"Failed to start DM")}let r=await a.json();m?.(r.conversation)}catch(e){u.default.error(e.message||"Couldn't start DM")}finally{b(!1)}return}if(w.length+S.length<1)return void u.default.error("Add at least one teammate or email");b(!0);try{let e=await fetch("/api/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"group",participantIds:w.map(e=>e._id),externalEmails:S,name:_.trim()})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||"Failed to create group")}let t=await e.json();m?.(t.conversation)}catch(e){u.default.error(e.message||"Couldn't create group")}finally{b(!1)}}}return(0,t.jsx)("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/30 backdrop-blur-sm",onClick:e,children:(0,t.jsxs)(r.motion.div,{initial:{y:12,opacity:0,scale:.96},animate:{y:0,opacity:1,scale:1},transition:{duration:.2,ease:[.25,.46,.45,.94]},className:"w-[460px] max-w-[94vw] rounded-2xl flex flex-col overflow-hidden",style:{background:"var(--surface-panel)",border:"1px solid var(--border-default)",boxShadow:"0 30px 80px var(--shadow-ambient-2xl)",maxHeight:"min(640px, 90vh)"},onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"h-[3px] flex-shrink-0 bg-gradient-to-r from-pink-500/60 via-orange-400/60 to-violet-500/60"}),(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-base font-bold text-gray-900 dark:text-zinc-100",children:"New conversation"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-zinc-500 mt-0.5",children:"dm"===f?"Direct message a teammate, or invite by email.":"Pick teammates and/or invite externals to start a group."})]}),(0,t.jsx)("button",{type:"button",onClick:e,className:"w-7 h-7 rounded-lg flex items-center justify-center hover:bg-gray-100 dark:hover:bg-zinc-900","aria-label":"Close",children:(0,t.jsx)(n.XMarkIcon,{className:"w-4 h-4"})})]}),(0,t.jsx)("div",{className:"px-4 pt-3 flex gap-1.5 flex-shrink-0",children:[{value:"dm",label:"Direct message",Icon:o.UserPlusIcon},{value:"group",label:"Group chat",Icon:l.UsersIcon}].map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{g(e.value),"dm"===e.value&&w.length>1&&N(w.slice(0,1))},className:"flex-1 inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded-xl text-[12px] font-bold transition-colors",style:f===e.value?{background:"rgba(236,72,153,0.10)",border:"1px solid rgba(236,72,153,0.28)",color:"#db2777"}:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-tertiary)"},children:[(0,t.jsx)(e.Icon,{className:"w-3.5 h-3.5"}),e.label]},e.value))}),(0,t.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 pt-3 pb-2",children:["group"===f&&(0,t.jsx)("input",{type:"text",value:_,onCh
1ange:e=>I(e.target.value),placeholder:"Group name (optional)",className:"w-full text-[13px] px-3 py-2 mb-3 rounded-xl focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-primary)"},maxLength:80}),(0,t.jsxs)("div",{className:"relative mb-2",children:[(0,t.jsx)(i.MagnifyingGlassIcon,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-zinc-500"}),(0,t.jsx)("input",{ref:D,type:"text",value:j,onChange:e=>k(e.target.value),placeholder:"Search teammates…",className:"w-full text-[13px] pl-9 pr-3 py-2 rounded-xl focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-primary)"}})]}),w.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-2",children:w.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>A(e),className:"inline-flex items-center gap-1.5 pl-1 pr-2 py-0.5 rounded-full text-[11px] font-bold",style:{background:"rgba(99,102,241,0.10)",border:"1px solid rgba(99,102,241,0.25)",color:"#4f46e5"},children:[(0,t.jsx)(x.default,{name:e.name,image:e.image,sizeClass:"w-4 h-4",textClass:"text-[7px]"}),e.name||e.email,(0,t.jsx)(n.XMarkIcon,{className:"w-3 h-3 opacity-60"})]},e._id))}),(0,t.jsx)("div",{className:"rounded-xl overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)"},children:0===T.length?(0,t.jsx)("div",{className:"text-[12px] text-gray-400 dark:text-zinc-500 italic px-3 py-3 text-center",children:j?"No teammates match":"No teammates found"}):T.slice(0,8).map(e=>{let a=!!w.find(t=>t._id===e._id);return(0,t.jsxs)("button",{type:"button",onClick:()=>A(e),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors hover:bg-gray-50 dark:hover:bg-zinc-900/60",style:a?{background:"rgba(99,102,241,0.06)"}:void 0,children:[(0,t.jsx)(x.default,{name:e.name,image:e.image,sizeClass:"w-7 h-7",textClass:"text-[10px]"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-[12px] font-bold text-gray-800 dark:text-zinc-100 truncate",children:e.name||e.email}),e.email&&e.name&&(0,t.jsx)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500 truncate",children:e.email})]}),a&&(0,t.jsx)(c.CheckIcon,{className:"w-4 h-4 text-indigo-500"})]},e._id)})}),(0,t.jsxs)("div",{className:"rounded-xl px-3 py-2.5 mb-2",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,t.jsx)(d.EnvelopeIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500"}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500",children:"Invite by email"})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{type:"email",value:z,onChange:e=>E(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),M())},placeholder:"[email protected]",className:"flex-1 text-[12px] px-2.5 py-1.5 rounded-lg focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-panel)",border:"1px solid var(--border-subtle)",color:"var(--text-primary)"}}),(0,t.jsx)("button",{type:"button",onClick:M,disabled:!z.trim(),className:"text-[11px] font-bold px-2.5 py-1 rounded-lg disabled:opacity-40",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)",color:"var(--text-tertiary)"},children:"Add"})]}),S.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:S.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{C(t=>t.filter(t=>t!==e))},className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold",style:{background:"var(--surface-panel)",border:"1px solid var(--border-subtle)",color:"var(--text-tertiary)"},children:[e,(0,t.jsx)(n.XMarkIcon,{className:"w-3 h-3 opacity-60"})]},e))})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 flex-shrink-0",style:{borderTop:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("button",{type:"button",onClick:e,className:"px-3 py-1.5 rounded-lg text-[12px] font-semibold text-gray-500 dark:text-zinc-400 hover:bg-gray-100 dark:hover:bg-zinc-900",children:"Cancel"}),(0,t.jsx)("button",{type:"button",onClick:L,disabled:h||("dm"===f?0===w.length&&0===S.length:w.length+S.length===0),className:"px-3.5 py-1.5 rounded-lg text-[12px] font-bold text-white disabled:opacity-40 transition-all",style:{background:"linear-gradient(135deg, #EC4899, #F97316)",boxShadow:"0 4px 12px rgba(236,72,153,0.25)"},children:h?"Starting…":"dm"===f?"Start DM":"Create group"})]})]})})}])},807576,77334,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(846932),s=e.i(88653),n=e.i(217255),i=e.i(618566),o=e.i(427217),l=e.i(847604),d=e.i(967969),c=e.i(416965),u=e.i(142663),x=e.i(87249),m=e.i(82291),p=e.i(174080),f=e.i(39875),g=e.i(562718),h=e.i(460759),b=e.i(766972),y=e.i(662060),v=e.i(705766),j=e.i(272857),k=e.i(666298);let w=["🎯","🚀","🔥","✨","⚡","💡","🌟","💼","📈","📊","🎬","🎙️","📣","🎨","🎭","🎵","🛍️","🍿","🥂","🏆","🎁","💎","🪩","🛼","🦄","🐉","🦊","🐼","🦁","🐙","🌈","☕️","🌶️","🍕","🍣","🍩","🌮","🥑","🍦","🍓","🌊","🌴","🏖️","🗽","🌃","🛰️","🛸","🪐"];function N({conversation:e,onClose:s,onSaved:i}){let{data:l}
1=(0,n.useSession)(),d=l?.user?._id?.toString(),c=!!(e?.participants||[]).some(e=>(e?._id?.toString?.()||e?.toString?.())===d)||l?.user?.role==="super_admin",[u,x]=(0,a.useState)(e?.name||""),[S,C]=(0,a.useState)(e?.image||""),[z,E]=(0,a.useState)(e?.participants||[]),[_,I]=(0,a.useState)(e?.externalParticipants||[]),[D,T]=(0,a.useState)(!1),[A,M]=(0,a.useState)(""),[L,O]=(0,a.useState)(""),[P,R]=(0,a.useState)(!1),$=(0,a.useRef)(null),[F,U]=(0,a.useState)(""),B=(0,j.default)({enabled:c}),G=(0,a.useMemo)(()=>{let e=new Set(z.map(e=>e?._id?.toString?.()||e?.toString?.())),t=A.trim().toLowerCase();return B.filter(a=>!(!a._id||e.has(a._id.toString()))&&a._id.toString()!==d&&(!t||(a.name||"").toLowerCase().includes(t)||(a.email||"").toLowerCase().includes(t))).slice(0,8)},[B,z,d,A]);async function H(t){let a=await fetch(`/api/conversations/${e._id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw Error("save_failed");return a.json()}async function K(){if(c){T(!0);try{let e=await H({name:u.trim(),image:S});i?.(e.conversation),v.default.success("Group updated")}catch{v.default.error("Couldn't save")}finally{T(!1)}}}async function W(e){E(t=>[...t,e]),M("");try{let t=await H({addParticipantIds:[e._id]});E(t.conversation.participants),i?.(t.conversation)}catch{E(z),v.default.error("Couldn't add teammate")}}async function J(e){let t=e?._id?.toString?.()||e?.toString?.();if(t&&(t!==d||window.confirm("Leave this group? You won't see new messages from it."))){E(e=>e.filter(e=>(e?._id?.toString?.()||e?.toString?.())!==t));try{let e=await H({removeParticipantIds:[t]});E(e.conversation.participants),i?.(e.conversation),t===d&&s?.()}catch{E(z),v.default.error("Couldn't remove member")}}}async function X(){let e=L.trim().toLowerCase();if(!e)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))return void v.default.error("That doesn't look like a valid email");let t={email:e,addedAt:new Date().toISOString()};I(e=>[...e,t]),O("");try{let t=await H({addExternalEmails:[e]});I(t.conversation.externalParticipants||[]),i?.(t.conversation)}catch{I(_),v.default.error("Couldn't add invitee")}}async function Y(e){I(t=>t.filter(t=>t.email.toLowerCase()!==e.toLowerCase()));try{let t=await H({removeExternalEmails:[e]});I(t.conversation.externalParticipants||[]),i?.(t.conversation)}catch{I(_),v.default.error("Couldn't remove invitee")}}async function q(t){if(t){R(!0);try{let a=await (0,k.uploadImage)(t,{folder:`conversations/${e._id}`});C(a);let r=await H({image:a});i?.(r.conversation),v.default.success("Image updated")}catch{v.default.error("Couldn't upload image")}finally{R(!1)}}}async function Q(e){let t=(e||"").trim();if(t){if(!function(e){if(!e||"string"!=typeof e)return!1;let t=e.trim();return!(!t||t.startsWith("http")||t.startsWith("/")||t.startsWith("data:"))&&Array.from(t).length<=6}(t))return void v.default.error("That doesn't look like an emoji");C(t),U("");try{let e=await H({image:t});i?.(e.conversation),v.default.success("Emoji set")}catch{C(S),v.default.error("Couldn't save emoji")}}}async function V(){if(S){C("");try{let e=await H({image:""});i?.(e.conversation)}catch{C(e.image||""),v.default.error("Couldn't clear image")}}}return((0,a.useEffect)(()=>{function e(e){"Escape"===e.key&&s?.()}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]),"u"<typeof document)?null:(0,p.createPortal)((0,t.jsx)("div",{className:"fixed inset-0 z-[210] flex items-center justify-center bg-black/30 backdrop-blur-sm",onClick:s,children:(0,t.jsxs)(r.motion.div,{initial:{y:12,opacity:0,scale:.96},animate:{y:0,opacity:1,scale:1},transition:{duration:.2,ease:[.25,.46,.45,.94]},className:"w-[480px] max-w-[94vw] rounded-2xl flex flex-col overflow-hidden",style:{background:"var(--surface-panel)",border:"1px solid var(--border-default)",boxShadow:"0 30px 80px var(--shadow-ambient-2xl)",maxHeight:"min(680px, 90vh)"},onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("div",{className:"h-[3px] flex-shrink-0 bg-gradient-to-r from-pink-500/60 via-orange-400/60 to-violet-500/60"}),(0,t.jsxs)("div",{className:"flex items-center gap-4 px-5 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,t.jsx)(m.default,{name:u||"Group",image:S,sizeClass:"w-14 h-14",textClass:"text-[16px]"}),c&&(0,t.jsx)("button",{type:"button",onClick:()=>$.current?.click(),disabled:P,className:"absolute -bottom-1 -right-1 w-7 h-7 rounded-full flex items-center justify-center text-white shadow-md disabled:opacity-50",style:{background:"linear-gradient(135deg, #EC4899, #F97316)"},title:"Upload an image",children:P?(0,t.jsx)("span",{className:"block w-3 h-3 border-2 border-white/40 border-t-white rounded-full animate-spin dark:border-zinc-800/40"}):(0,t.jsx)(g.PhotoIcon,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("input",{ref:$,type:"file",accept:"image/*",className:"hidden",onChange:e=>{let t=e.target.files?.[0];t&&q(t),e.target.value=""}})]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("input",{type:"text",value:u,onChange:e=>x(e.target.value),onBlur:()=>{(u||"").trim()!==(e?.name||"")&&K()},onKeyDown:e=>{"Enter"===e.key&&e.target.blur()},placeholder:"Group name",maxLength:80,disabled:!c||D,className:"w-full text-[16px] font-bold bg-transparent text-gray-900 dark:text-zinc-100 px-0 py-1 focus:outline-none border-b border-transparent focus:border-orange-300/50 transition-colors"}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-gray-400 dark:text-zinc-500 mt-1",children:[(0,t.jsxs)("span",{children:[z.length," ",1===z.length?"member":"members"]}),_.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{children:"·"}
1),(0,t.jsxs)("span",{children:[_.length," invited by email"]})]}),S&&c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{children:"·"}),(0,t.jsx)("button",{type:"button",onClick:V,className:"hover:text-gray-700 dark:hover:text-zinc-300",children:"Clear image"})]})]})]}),(0,t.jsx)("button",{type:"button",onClick:s,className:"w-7 h-7 rounded-lg flex items-center justify-center hover:bg-gray-100 dark:hover:bg-zinc-900","aria-label":"Close",children:(0,t.jsx)(o.XMarkIcon,{className:"w-4 h-4"})})]}),(0,t.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-5",children:[c&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500 mb-2 block",children:"Group avatar"}),(0,t.jsx)("div",{className:"text-[11px] text-gray-500 dark:text-zinc-400 mb-2",children:"Pick an emoji or type your own. Use the camera badge on the avatar to upload an image instead."}),(0,t.jsx)("div",{className:"grid grid-cols-12 gap-1 mb-2.5",children:w.map(e=>{let a=String(S||"").trim()===e;return(0,t.jsx)("button",{type:"button",onClick:()=>Q(e),className:"w-7 h-7 rounded-md flex items-center justify-center text-base leading-none transition-colors",style:{background:a?"linear-gradient(135deg, rgba(139,92,246,0.15), rgba(99,102,241,0.15))":"transparent",border:a?"1px solid rgba(99,102,241,0.45)":"1px solid transparent"},onMouseEnter:e=>{a||(e.currentTarget.style.background="var(--surface-soft)")},onMouseLeave:e=>{a||(e.currentTarget.style.background="transparent")},title:`Use ${e}`,children:e},e)})}),(0,t.jsxs)("div",{className:"flex gap-1.5",children:[(0,t.jsx)("input",{type:"text",value:F,onChange:e=>U(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),Q(F))},placeholder:"Type or paste any emoji…",className:"flex-1 text-sm px-3 py-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-violet-300/50",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"}}),(0,t.jsx)("button",{type:"button",onClick:()=>Q(F),disabled:!F.trim(),className:"px-4 rounded-lg text-xs font-bold text-white disabled:opacity-40 transition-opacity",style:{background:"linear-gradient(135deg, #8b5cf6, #6366f1)"},children:"Set"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500 mb-2 block",children:"Members"}),(0,t.jsx)("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:z.map(e=>{let a=e?._id?.toString?.()||e?.toString?.(),r=a===d;return(0,t.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2 hover:bg-gray-50 dark:hover:bg-zinc-900/60",children:[(0,t.jsx)(m.default,{name:e.name,image:e.image,sizeClass:"w-7 h-7",textClass:"text-[10px]"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"text-[12.5px] font-bold text-gray-800 dark:text-zinc-100 truncate",children:[e.name||e.email||"Member",r&&(0,t.jsx)("span",{className:"ml-1.5 text-[10px] font-medium text-gray-400 dark:text-zinc-500",children:"(you)"})]}),e.email&&e.name&&(0,t.jsx)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500 truncate",children:e.email})]}),c&&(0,t.jsx)("button",{type:"button",onClick:()=>J(e),className:"text-gray-300 dark:text-zinc-700 hover:text-red-500 p-1 rounded",title:r?"Leave group":"Remove member",children:(0,t.jsx)(h.TrashIcon,{className:"w-3.5 h-3.5"})})]},a)})})]}),c&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500 mb-2 block flex items-center gap-1.5",children:[(0,t.jsx)(y.UserPlusIcon,{className:"w-3 h-3"}),"Add a teammate"]}),(0,t.jsxs)("div",{className:"relative mb-2",children:[(0,t.jsx)(f.MagnifyingGlassIcon,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-zinc-500"}),(0,t.jsx)("input",{type:"text",value:A,onChange:e=>M(e.target.value),placeholder:"Search teammates…",className:"w-full text-[13px] pl-9 pr-3 py-2 rounded-xl focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-primary)"}})]}),G.length>0&&(0,t.jsx)("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:G.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>W(e),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-gray-50 dark:hover:bg-zinc-900/60",children:[(0,t.jsx)(m.default,{name:e.name,image:e.image,sizeClass:"w-7 h-7",textClass:"text-[10px]"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-[12.5px] font-bold text-gray-800 dark:text-zinc-100 truncate",children:e.name||e.email}),e.email&&e.name&&(0,t.jsx)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500 truncate",children:e.email})]}),(0,t.jsx)("span",{className:"text-[10px] font-bold text-orange-500",children:"+ Add"})]},e._id))}),A.trim()&&0===G.length&&(0,t.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-zinc-500 italic px-1",children:"No teammates match."})]}),(c||_.length>0)&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500 mb-2 block flex items-center gap-1.5",children:[(0,t.jsx)(b.EnvelopeIcon,{className:"w-3 h-3"}),"Invited by email"]}),_.length>0&&(0,t.jsx)("div",{className:"rounded-xl overflow-hidden mb-2",style:{border:"1px solid var(--border-subtle)"},children:_.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[(0,t.jsx)("div",{className:"w-7 h-7 rounded-full flex items-center justify-center",style:{background:"var(--surface-softer)"},children:(0,t.jsx)(b.EnvelopeIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-[12px] font-bold text-gray-800 dark:text-zinc-100 truncate",children:e.email}),e.addedAt&&(0,t.jsxs)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500",children:["Invited"," ",new Date(e.addedAt).toLocaleDateString()]})]}),c&&(0,t.jsx)("button",{type:"button",onClick:()=>Y(e.email),className:"text-gray-300 dark:text-zinc-700 hover:text-red-500 p-1 rounded",title:"Remove invitee",children:(0,t.jsx)(h.TrashIcon,{className:"w-3.5 h-3.5"})})]},e.email))}),c&&(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{type:"email",value:L,onChange:e=>O(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),X())},placeholder:"[email protected]",className:"flex-1 text-[12px] px-3 py-1.5 rounded-lg focus:outline-none focus:ring-2 focus:ring-orange-300/40",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)",color:"var(--text-primary)"}}),(0,t.jsx)("button",{type:"button",onClick:X,disabled:!L.trim(),className:"text-[11px] font-bold px-2.5 py-1 rounded-lg disabled:opacity-40",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)",color:"var(--text-tertiary)"},children:"Invite"})]})]})]})]})}),document.body)}e.s(["default",0,N],77334);var S=e.i(809182);function C({conversationId:e,session:s,onClose:n,onMinimize:i,onExpand:l,isMobile:p=!1}){let{getCachedConversation:f,cacheConversation:g}=(0,u.useConversation)(),[h,b]=(0,a.useState)(()=>f(e)),[y,v]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let t=!1;return fetch(`/api/conversations/${e}`).then(e=>e.ok?e.json():null).then(e=>{!t&&e?.conversation&&(b(e.conversation),g(e.conversation))}).catch(()=>{}),()=>{t=!0}},[e,g]);let j=function(e,t){if(!e||!Array.isArray(e.participants))return null;let a=t?.user?._id?.toString(),r=e.participants.find(e=>(e?._id?.toString?.()||e?.toString?.())!==a);if(r)return r;let s=(e.externalParticipants||[])[0];return s?{name:s.name||s.email,email:s.email,image:null}:null}(h,s),k=h?.type==="group"?h?.name||"Group chat":j?.name||j?.email||"Direct message",w=h?.type==="group"?h?.image:j?.image,E=h?.type==="group"?null:j?._id,_=(0,S.useIsUserOnline)(E);return(0,t.jsxs)(r.motion.div,{layout:!0,layoutId:`conv-frame-${e}`,initial:{y:16,opacity:0,scale:.96},animate:{y:0,opacity:1,scale:1},exit:{y:16,opacity:0,scale:.96},transition:{duration:.22,ease:[.25,.46,.45,.94],layout:{type:"spring",stiffness:220,damping:30,mass:.9}},className:`pointer-events-auto flex flex-col overflow-hidden ${p?"w-full":"w-[320px] sm:w-[340px]"}`,style:{height:p?"min(70dvh, calc(100dvh - 4rem - env(safe-area-inset-bottom) - 5rem))":"min(540px, calc(100vh - 8rem))",background:"var(--surface-panel)",border:"1px solid var(--border-default)",borderRadius:16,boxShadow:"0 20px 50px var(--shadow-ambient-xl), 0 4px 14px var(--shadow-ambient-md)",backdropFilter:"blur(24px)"},children:[(0,t.jsx)("div",{className:"absolute inset-x-0 top-0 h-[2px] bg-gradient-to-r from-pink-500/60 via-orange-400/60 to-violet-500/60"}),(0,t.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,t.jsx)(m.default,{name:k,image:w,sizeClass:"w-8 h-8",textClass:"text-[10px]"}),h?.type!=="group"&&_&&(0,t.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full",style:{background:"#10b981",boxShadow:"0 0 0 2px var(--surface-panel), 0 0 6px rgba(16,185,129,0.45)"},"aria-label":"Online",title:"Online"})]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-[13px] font-bold text-gray-900 dark:text-zinc-100 truncate",children:k}),h?.type==="group"?(0,t.jsxs)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500 truncate",children:[h.participants?.length||0," members"]}):(0,t.jsx)("div",{className:`text-[10px] truncate ${_?"text-emerald-500 dark:text-emerald-400":"text-gray-400 dark:text-zinc-500"}`,children:_?"Online":"Offline"})]}),h?.type==="group"&&(0,t.jsx)("button",{type:"button",onClick:()=>v(!0),className:"w-7 h-7 rounded-lg flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:bg-gray-100 dark:hover:bg-zinc-900",title:"Group info",children:(0,t.jsx)(d.EllipsisHorizontalIcon,{className:"w-4 h-4"})}),l&&!p&&(0,t.jsx)(z,{onClick:l,title:"Expand to full screen","aria-label":"Expand to full screen",shimmerKey:e,children:(0,t.jsx)(c.ArrowsPointingOutIcon,{className:"w-4 h-4"})}),(0,t.jsx)("button",{type:"button",onClick:n,className:"w-7 h-7 rounded-lg flex items-center justify-center text-gray-400 dark:text-zinc-500 hover:bg-gray-100 dark:hover:bg-zinc-900",title:"Close",children:(0,t.jsx)(o.XMarkIcon,{className:"w-4 h-4"})})]}),(0,t.jsx)("div",{className:"relative flex-1 min-h-0 flex flex-col",children:(0,t.jsx)(x.default,{conversationId:e,session:s})}),y&&h&&(0,t.jsx)(N,{conversation:h,onClose:()=>v(!1),onSaved:e=>b(e)})]})}function z({onClick:e,title:s,ariaLabel:n,children:i,shimmerKey:o,sizeClassName:l="w-7 h-7",colorClassName:d="text-gray-400 dark:text-zinc-500 hover:bg-gray-100 dark:hover:bg-zinc-900",className:c="",...u}){let[x,m]=(0,a.useState)(!0);return(0,a.useEffect)(()=>{m(!0);let e=setTimeout(()=>m(!1),1100);return()=>clearTimeout(e)},[o]),(0,t.jsxs)(r.motion.button,{type:"button",onClick:e,title:s,"aria-label":n||s,animate:x?{boxSh
1adow:["0 0 0 0 rgba(249,115,22,0)","0 0 10px 1px rgba(249,115,22,0.35)","0 0 6px 1px rgba(249,115,22,0.20)","0 0 0 0 rgba(249,115,22,0)"]}:{boxShadow:"0 0 0 0 rgba(249,115,22,0)"},transition:{duration:1.1,ease:"easeInOut",times:[0,.25,.7,1]},className:`relative ${l} rounded-lg flex items-center justify-center ${d} overflow-hidden ${c}`,...u,children:[i,x&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.motion.span,{"aria-hidden":"true",className:"absolute inset-0 pointer-events-none",initial:{x:"-105%",opacity:0},animate:{x:"105%",opacity:[0,1,1,0]},transition:{x:{duration:.95,ease:"easeInOut"},opacity:{duration:.95,times:[0,.18,.82,1],ease:"easeInOut"}},style:{background:"linear-gradient(110deg, transparent 38%, rgba(255,210,170,0.85) 50%, transparent 62%)",mixBlendMode:"plus-lighter"}}),(0,t.jsx)(r.motion.span,{"aria-hidden":"true",className:"absolute inset-0 pointer-events-none",initial:{x:"-105%",opacity:0},animate:{x:"105%",opacity:[0,.95,0]},transition:{x:{duration:.7,ease:"easeOut",delay:.32},opacity:{duration:.7,times:[0,.4,1],ease:"easeOut",delay:.32}},style:{background:"linear-gradient(110deg, transparent 46%, var(--panel-95) 50%, transparent 54%)",mixBlendMode:"plus-lighter"}})]})]})}e.s(["AttentionButton",0,z,"default",0,function(){let{data:e,status:r}
1=(0,n.useSession)(),o=(0,i.usePathname)()||"",d=(0,i.useRouter)(),{visibleIds:c,collapsedIds:x,open:m,close:p,collapse:f}=(0,u.useConversation)(),g=function(){let[e,t]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{if(!window.matchMedia)return;let e=window.matchMedia("(max-width: 767px)"),a=()=>t(e.matches);return a(),e.addEventListener?.("change",a),()=>e.removeEventListener?.("change",a)},[]),e}();if("authenticated"!==r||o.startsWith("/dashboard/messages")||0===c.length&&0===x.length)return null;let h=g?c.slice(0,1):c,b=g?c.length-1:0,y=x.length+Math.max(0,b),v=g?c.slice(1):[];return(0,t.jsxs)("div",{className:`fixed z-[80] flex items-end pointer-events-none
2        ${g?"left-2 right-2 bottom-[calc(4rem+env(safe-area-inset-bottom)+0.5rem)] flex-col gap-2":"right-4 bottom-4 gap-3"}`,children:[(0,t.jsx)(s.AnimatePresence,{children:h.map(a=>(0,t.jsx)(C,{conversationId:a,session:e,isMobile:g,onClose:()=>p(a),onMinimize:()=>f(a),onExpand:()=>{d.push(`/dashboard/messages?c=${a}`)}},a))}),y>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>{[...x,...v].forEach(m)},className:"pointer-events-auto inline-flex items-center gap-1.5 px-3 h-9 rounded-full text-xs font-bold shadow-lg self-end",style:{background:"var(--surface-panel)",border:"1px solid var(--border-default)",color:"var(--text-tertiary)"},title:`${y} more conversation${1===y?"":"s"}`,children:[(0,t.jsx)(l.ChatBubbleLeftRightIcon,{className:"w-3.5 h-3.5"}),"+",y]})]})}],807576)},87249,e=>{"use strict";var t=e.i(247167),a=e.i(843476),r=e.i(271645),s=e.i(705766),n=e.i(846932),i=e.i(88653),o=e.i(427217),l=e.i(871822),d=e.i(591160),c=e.i(313004),u=e.i(272857),x=e.i(864043);let m="true"===t.default.env.NEXT_PUBLIC_CHAT_TASK_SUGGEST;function p({suggestion:e,onDismiss:t,onAccepted:r}){let s={kind:"message",id:e.messageId,seedTitle:e.suggestedTitle,seedAssignees:e.suggestedAssignees,seedCollaborators:e.suggestedCollaborators,seedDueDate:e.dueDate??void 0,label:"Created from a message"};return(0,a.jsx)(i.AnimatePresence,{children:(0,a.jsxs)(n.motion.div,{initial:{opacity:0,y:6,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:4,scale:.97},transition:{duration:.22,ease:[.25,.46,.45,.94]},className:"flex items-center gap-2 px-3 py-2 mx-4 sm:mx-6 mb-1 rounded-2xl",style:{background:"rgba(99,102,241,0.06)",border:"1px solid rgba(99,102,241,0.18)"},children:[(0,a.jsx)("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(99,102,241,0.10)"},children:(0,a.jsx)(l.ListBulletIcon,{className:"w-4 h-4 text-indigo-500"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-[12px] font-semibold text-gray-700 dark:text-zinc-200 truncate",children:"Turn this into a task?"}),e.suggestedTitle&&(0,a.jsxs)("p",{className:"text-[11px] text-gray-500 dark:text-zinc-400 truncate",children:["“",e.suggestedTitle,"”"]})]}),(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(x.default,{context:s,variant:"button",label:"Create",onCreated:()=>{r?.()}})}),(0,a.jsx)("button",{type:"button",onClick:t,className:"flex-shrink-0 p-2.5 -m-1.5 rounded-xl text-gray-400 dark:text-zinc-500 hover:text-gray-600 dark:hover:text-zinc-300 hover:bg-gray-100 dark:hover:bg-zinc-800 transition-colors","aria-label":"Dismiss task suggestion",title:"Dismiss",children:(0,a.jsx)(o.XMarkIcon,{className:"w-4 h-4"})})]},"task-suggest-chip")})}function f(e,t,a){let r=t.toString(),s=new Date(a).getTime(),n=Array.isArray(e.readState)?e.readState:[],i=!1,o=n.map(e=>(e.user?.toString?.()||e.user)!==r?e:(i=!0,(e.lastReadAt?new Date(e.lastReadAt).getTime():0)>=s?e:{...e,lastReadAt:a}));return i||o.push({user:r,lastReadAt:a}),{...e,readState:o}}e.s(["default",0,function({conversationId:t,session:n,teamMembers:i,onChanged:o,highlightedMessageId:l=null}){let[x,g]=(0,r.useState)([]),[h,b]=(0,r.useState)(!1),[y,v]=(0,r.useState)(null),[j,k]=(0,r.useState)(null),w=(0,r.useRef)(new Set),N=(0,u.default)({enabled:!i||0===i.length}),S=i&&i.length>0?i:N,C=(0,r.useMemo)(()=>({type:"conversation",id:t}),[t]),{typers:z,notifyTyping:E,clearTyping:_}=(0,c.default)({parent:C,selfUserId:n?.user?._id}),I=(0,r.useRef)(o);(0,r.useEffect)(()=>{I.current=o},[o]);let D=(0,r.useCallback)(async()=>
2{if(t)try{let e=await fetch(`/api/messages?parent=conversation:${encodeURIComponent(t)}`);if(!e.ok)return;let a=(await e.json()).messages||[],r=function(e){let t=new Map,a=[];for(let r of e)if(r.parentMessage){let e=r.parentMessage.toString(),a=t.get(e)||[];a.push(r),t.set(e,a)}else a.push(r);for(let e of(a.sort((e,t)=>new Date(e.createdAt)-new Date(t.createdAt)),t.values()))e.sort((e,t)=>new Date(e.createdAt)-new Date(t.createdAt));return a.map(e=>({...e,replies:t.get(e._id?.toString?.())||[]}))}(a);g(r),I.current?.(a)}catch(e){console.error("ConversationMessageThread fetch failed:",e)}finally{b(!0)}},[t]);(0,r.useEffect)(()=>{D()},[D]);let T=(0,r.useCallback)(async()=>{if(t)try{let e=await fetch(`/api/conversations/${t}`);if(!e.ok)return;let a=await e.json();a?.conversation&&v(a.conversation)}catch{}},[t]);(0,r.useEffect)(()=>{T()},[T]),(0,r.useEffect)(()=>{if(!t)return;let e=n?.user?._id?.toString?.();fetch(`/api/conversations/${t}/read`,{method:"POST"}).then(e=>e.ok?e.json():null).then(a=>{a?.lastReadAt&&e&&(v(t=>t?f(t,e,a.lastReadAt):t),window.dispatchEvent(new CustomEvent("ss-conversation-event",{detail:{kind:"self_read",conversationId:t?.toString?.()||t,lastReadAt:a.lastReadAt,user:{_id:e}}})),window.dispatchEvent(new CustomEvent("ss-notifications-changed")))}).catch(()=>{})},[t,n?.user?._id]),(0,r.useEffect)(()=>{function e(e){let a=e.detail||{};if("message_updated"===a.kind){let{messageId:e,spawnedTask:t}=a;if(!e||!t)return;g(a=>{var r,s,n;let i,o,l;return r=a,s=e,n=t,i=s?.toString?.()||s,o=!1,l=r.map(e=>{let t=e._id?.toString?.()||e._id,a=(e.replies||[]).map(e=>(e._id?.toString?.()||e._id)!==i?e:(o=!0,{...e,spawnedTask:n}));return t===i?(o=!0,{...e,spawnedTask:n,replies:a}):a!==e.replies?{...e,replies:a}:e}),o?l:r});return}if((a.conversationId?.toString?.()||a.parent?.id?.toString?.())===t?.toString?.()){if("read"===a.kind){let e=a.user?._id?.toString?.(),t=a.lastReadAt;if(!e||!t)return;v(a=>a?f(a,e,t):a);return}D(),"u">typeof document&&"hidden"===document.visibilityState||fetch(`/api/conversations/${t}/read`,{method:"POST"}).catch(()=>{})}}return window.addEventListener("ss-conversation-event",e),()=>window.removeEventListener("ss-conversation-event",e)},[t,D]),(0,r.useEffect)(()=>{if(t)return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e);function e(){"visible"===document.visibilityState&&fetch(`/api/conversations/${t}/read`,{method:"POST"}).catch(()=>{})}},[t]);let A=(0,r.useMemo)(()=>{if(!y)return[];let e=n?.user?._id?.toString?.(),t=new Map((Array.isArray(y.participants)?y.participants:[]).map(e=>[e._id?.toString?.()||String(e._id),e])),a=new Map;for(let r of y.readState||[]){let s=r.user?.toString?.()||r.user;if(!s||e&&s===e)continue;let n=t.get(s);if(!n)continue;let i=r.lastReadAt?new Date(r.lastReadAt).getTime():0,o=a.get(s);o&&o.t>=i||a.set(s,{t:i,entry:{user:{_id:n._id,name:n.name,image:n.image},readAt:r.lastReadAt}})}return[...a.values()].map(e=>e.entry)},[y,n?.user?._id]);async function M({text:a,mentions:r,creatorMentions:i,campaignMentions:o,organizationMentions:l,dealMentions:d,media:c}){try{let s=await fetch("/api/messages",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:{type:"conversation",id:t},text:a,mentions:r,creatorMentions:i,campaignMentions:o,organizationMentions:l,dealMentions:d,media:c})});if(!s.ok)throw Error("send_failed");if(_(),m&&a?.trim()){let r=await s.clone().json().catch(()=>null),i=r?.message;if(i?._id){let r=n?.user?._id?.toString?.(),s=(y?.participants||[]).map(e=>e._id?.toString?.()||String(e._id)).find(e=>e!==r)||null;e.A(37782).then(({detectTaskSuggestion:e})=>{let n=e(a.trim(),{senderId:r,otherParticipantId:s,messageId:i._id?.toString?.(),conversationId:t?.toString?.()});n.isActionable&&!w.current.has(n.messageId)&&k(n)}).catch(()=>{})}}D()}catch{s.default.error("Failed to send")}}async function L(e,a,r){try{if(!(await fetch("/api/messages",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:{type:"conversation",id:t},text:a,parentMessage:e,replyTo:r||null})})).ok)throw Error("send_failed");D()}catch{s.default.error("Failed to reply")}}async function O(e,t,a){try{if(!(await fetch(`/api/messages/${t||e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:a})})).ok)throw Error("edit_failed");D()}catch(e){throw s.default.error(e.message||"Couldn't save edit"),e}}async function P(e,t){try{if(!(await fetch(`/api/messages/${t||e}`,{method:"DELETE"})).ok)throw Error("delete_failed");D()}catch{s.default.error("Couldn't delete")}}async function R(e,t,a){try{if(!(await fetch(`/api/messages/${a||e}/reactions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({emoji:t})})).ok)throw Error("react_failed");D()}catch{s.default.error("Failed to react")}}if(!h)return(0,a.jsx)("div",{className:"flex-1 min-h-0"});let $=m&&j?(0,a.jsx)(p,{suggestion:j,onDismiss:()=>{w.current.add(j.messageId),k(null)},onAccepted:()=>k(null)}):null;return(0,a.jsx)(d.default,{messages:x,currentUserId:n?.user?._id,isAdmin:["admin","super_admin"].includes(n?.user?.role),teamMembers:S,composerPlaceholder:"Message…",composerCta:"Send",readBy:A,showReadReceipts:!0,onSubmit:M,onEditMessage:O,onDeleteMessage:P,onToggleReaction:R,onAddReply:L,senderName:n?.user?.name,senderImage:n?.user?.image,onComposerActivity:E,typers:z,highlightedMessageId:l,suggestionBanner:$})}])}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.