PageSourceSearch

https://dashboard.refocus.co.in/_next/static/chunks/5764-ad2f0b6cb…?dpl=dpl_Mv5uTHtJaqyGqycLS6mNPbztdnDX

js refocus.co.in collected 2026-10-02 01:55:51 UTC 35,182 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5764],{33526:(e,t,r)=>{r.d(t,{A:()=>p});var s=r(95155),a=r(12115),n=r(35137),i=r(14856),l=r(31993),o=r(40048),d=r(37882),c=r(38410),u=r(97657),m=r(95885);function f({canInteract:e,verifyMessage:t,friendLabel:r,isModal:i,srOpen:l,setSrOpen:o,onSend:d}){let[c,u]=(0,a.useState)(""),[m,x]=(0,a.useState)(!1),p=async()=>{let t=c.trim();if(t&&e&&!m){u(""),x(!0);try{await d(t)}finally{x(!1)}}};return(0,s.jsx)("div",{className:`shrink-0 border-t border-rf-line/70 bg-rf-card ${i?"px-5 py-4":"p-3"}`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"text",placeholder:e?`Message ${r.split(/[@\s]/)[0]||"friend"}…`:t||"",disabled:!e||m,className:`flex-1 rounded-full border border-rf-line bg-rf-bg text-rf-ink placeholder:text-rf-ink-mute focus:outline-none focus:border-rf-primary focus:bg-rf-line-soft transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${i?"px-4 py-2 text-sm":"px-3 py-1.5 text-sm"}`,value:c,onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),p())}}),(0,s.jsx)("button",{onClick:()=>e&&o(e=>!e),disabled:!e,"aria-label":l?"Close session request":"Send session request",title:e?"Send session request":t||"",className:`inline-flex shrink-0 items-center justify-center rounded-full border transition-colors ${l?"border-rf-primary bg-rf-cream-bg text-rf-plum-ink":"border-rf-line bg-rf-card text-rf-ink-soft hover:bg-rf-line-soft hover:text-rf-plum-ink"} ${i?"h-10 w-10":"h-8 w-8"}`,children:(0,s.jsx)(n.wIk,{size:i?16:14})}),(0,s.jsx)("button",{onClick:p,disabled:!e||m||!c.trim(),"aria-label":"Send message",className:`inline-flex shrink-0 items-center justify-center rounded-full bg-rf-primary text-rf-on-primary shadow-sm hover:bg-rf-primary-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors ${i?"h-10 w-10":"h-8 w-8"}`,children:(0,s.jsx)(n.kGk,{size:i?16:14})})]})})}var x=r(4740);function p({friendId:e,friendLabel:t,friendAvatarUrl:r,friendIsAdmin:h=!1,onClose:g,layout:b="modal",minimized:y=!1,onMinimizeToggle:w}){let k,j,{data:v}=(0,d.useSession)(),N=function(){let{data:e}=(0,d.useSession)(),[t,r]=(0,a.useState)(e?.user?.image??null);return(0,a.useEffect)(()=>{let t=e?.user?.image?.trim();if(t)return void r(t);let s=!1;return(async()=>{try{let e=await fetch("/api/users/me"),t=await e.json().catch(()=>({}));!s&&e.ok&&r(t?.user?.avatarUrl??null)}catch{}})(),()=>{s=!0}},[e?.user?.image]),t}(),{canInteract:S,message:C}=(0,o.c)(),[$,D]=(0,a.useState)([]),[_,F]=(0,a.useState)(!1),[E,I]=(0,a.useState)(null),[T,A]=(0,a.useState)(null),[q,M]=(0,a.useState)(!1),[O,L]=(0,a.useState)(null),[R,P]=(0,a.useState)(null),[z,H]=(0,a.useState)(0),[Y,U]=(0,a.useState)(x.jI),[B,V]=(0,a.useState)(""),[G,J]=(0,a.useState)(""),[W,K]=(0,a.useState)(!1),[Q,X]=(0,a.useState)({myBusySlots:[],friendBusySlots:[]}),[Z,ee]=(0,a.useState)(!1),[et,er]=(0,a.useState)(null),[es,ea]=(0,a.useState)(""),[en,ei]=(0,a.useState)(new Set),[el,eo]=(0,a.useState)(null),[ed,ec]=(0,a.useState)(null),[eu,em]=(0,a.useState)(()=>Date.now());(0,a.useEffect)(()=>{let e=setInterval(()=>em(Date.now()),6e4);return()=>clearInterval(e)},[]),(0,a.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/users/preferences");if(!t.ok)return;let r=await t.json().catch(()=>({})),s=r?.preferences?.defaultSessionLength;!e&&"number"==typeof s&&(0,x.di)(s)&&U(s)}catch{}})(),()=>{e=!0}},[]),(0,a.useEffect)(()=>{if(!el)return;let e=e=>{let t=e.target;t&&t.closest("[data-chat-message-menu]")||eo(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[el]);let ef=(0,a.useCallback)(e=>{let t=new Date,r=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),s=Math.round((r(t)-r(e))/864e5);return 0===s?"Today":1===s?"Yesterday":s>1&&s<7?e.toLocaleDateString(void 0,{weekday:"long"}):e.toLocaleDateString(void 0,{month:"long",day:"numeric",...e.getFullYear()!==t.getFullYear()?{year:"numeric"}:{}})},[]),ex=(0,a.useCallback)(e=>new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),[]),ep=async()=>
1{if(G.trim()){K(!0);try{let e=await fetch("/api/ai/refine-goal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal:G})}),t=await e.json();t.refinedGoal&&J(t.refinedGoal)}catch(e){console.error(e)}finally{K(!1)}}};(0,a.useEffect)(()=>{q&&(async()=>{ee(!0);try{let t=new Date;t.setHours(0,0,0,0);let r=new Date(t);r.setDate(r.getDate()+8);let s=await fetch(`/api/sessions/busy?from=${t.toISOString()}&to=${r.toISOString()}&friendId=${e}`);if(s.ok){let e=await s.json();X(e)}}catch{}finally{ee(!1)}})()},[q,e]);let eh=(0,a.useCallback)((e,t,r,s)=>{if(!e)return{hasConflict:!1,isMine:!1,isFriend:!1};let a=new Date(e);a.setHours(t,r,0,0);let n=new Date(a.getTime()+6e4*s),i=a.getTime(),l=n.getTime(),o=!1,d=!1;for(let e of Q.myBusySlots){let t=new Date(e.start).getTime();if(i<new Date(e.end).getTime()&&l>t){o=!0;break}}for(let e of Q.friendBusySlots){let t=new Date(e.start).getTime();if(i<new Date(e.end).getTime()&&l>t){d=!0;break}}return{hasConflict:o||d,isMine:o,isFriend:d}},[Q]),eg=(0,a.useMemo)(()=>{let e=new Date(eu);e.setHours(0,0,0,0);let t=[],r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let s=0;s<7;s++){let a,n=new Date(e);n.setDate(n.getDate()+s),a=0===s?"Today":1===s?"Tomorrow":`${r[n.getDay()]} ${n.getDate()}`,t.push({label:a,date:n})}return t},[eu]),eb=(0,a.useMemo)(()=>{let e=[];for(let t=0;t<=23;t++){let r=t>=12?"PM":"AM",s=t%12||12;e.push({hour:t,label:`${s} ${r}`})}return e},[]),ey=(0,a.useCallback)((e,t)=>{if(!e)return!1;let r=new Date(eu),s=new Date(e);return s.setHours(t,0,0,0),s<=r},[eu]),[ew,ek]=(0,a.useState)({}),ej=(0,a.useRef)(null),ev=(0,a.useRef)(!0),eN=(0,a.useCallback)((e="auto")=>{let t=ej.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e})},[]),eS=(0,a.useCallback)(()=>{let e=ej.current;e&&(ev.current=e.scrollHeight-(e.scrollTop+e.clientHeight)<80)},[]),eC=(0,a.useCallback)(async()=>{F(!0),I(null);try{let t=await fetch(`/api/chat/${e}`),r=await t.json();if(!t.ok)throw Error(r.error||"Failed to load chat");let s=r.messages||[];D(e=>{let t=e.filter(e=>e.id.startsWith("temp-"));if(0===t.length)return s;let r=new Set(s.map(e=>e.id));return[...s,...t.filter(e=>!r.has(e.id))]}),A(r.currentUserId||null),ev.current=!0,requestAnimationFrame(()=>eN());try{await fetch(`/api/chat/${e}/read`,{method:"POST"})}catch{}}catch(e){I(e.message)}finally{F(!1)}},[e,eN]);(0,a.useEffect)(()=>{eC();let t=!1,r=T?(0,l.cE)(T,e):null;if(!r)return;let s=(0,i.Y)().channels.get(r),a=r=>{if(t)return;let s=r.data;if(s?.type){if(("message:new"===s.type||"session-request:new"===s.type)&&s.payload){let t=s.payload;if(t.id){D(e=>{if(e.some(e=>e.id===t.id))return e;let r=e.findIndex(e=>e.id.startsWith("temp-")&&e.from_user_id===t.from_user_id&&e.content===t.content);if(-1!==r){let s=[...e];return s[r]=t,s}let s=e.filter(e=>!(e.id.startsWith("temp-")&&e.from_user_id===t.from_user_id&&e.content===t.content));return s.some(e=>e.id===t.id)?s:[...s,t]});try{fetch(`/api/chat/${e}/read`,{method:"POST"})}catch{}return}}if("message:updated"===s.type&&s.payload){let e=s.payload;if(e.id&&"string"==typeof e.content)return void D(t=>t.map(t=>t.id===e.id?{...t,content:e.content,edited_at:e.edited_at??new Date().toISOString(),deleted:!1}:t))}if("message:deleted"===s.type&&s.payload){let e=s.payload;if(e.id)return void D(t=>t.map(t=>t.id===e.id?{...t,content:e.content??"[This message was deleted]",deleted:!0,deleted_at:e.deleted_at??new Date().toISOString(),edited_at:null}:t))}eC()}};return s.subscribe("event",a),()=>{t=!0,s.unsubscribe("event",a)}},[T,e,eC]),(0,a.useEffect)(()=>{ev.current&&requestAnimationFrame(()=>eN())},[$,eN]);let e$=async t=>{if(!t||!T||!S)return;let r=`temp-${Date.now()}-${Math.random().toString(36).slice(2)}`,s={id:r,from_user_id:T,to_user_id:e,type:"text",content:t,created_at:new Date().toISOString()};D(e=>[...e,s]),I(null);try{let s=await fetch(`/api/chat/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"text",content:t})}),a=await s.json();if(!s.ok)throw Error(a.error||"Failed to send");D(e=>e.some(e=>e.id===a.id||e.id!==r&&e.content===t&&e.from_user_id===T)?e.filter(e=>e.id!==r):e.map(e=>e.id===r?{...e,id:a.id}:e)),ev.current=!0,requestAnimationFrame(()=>eN("smooth"))}catch(e){throw D(e=>e.filter(e=>e.id!==r)),I(e.message),e}},eD=async()=>
1{if(S)try{if(!O||null===R)throw Error("Pick date & time");let t=new Date(O);if(t.setHours(R,z,0,0),t<=new Date)throw Error("Cannot schedule in the past");let r=t.toISOString(),s=await fetch(`/api/chat/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"session-request",start:r,durationMin:Y,message:B||void 0,goal:G||void 0})}),a=await s.json();if(!s.ok)throw Error(a.error||"Failed to send request");M(!1),L(null),P(null),H(0),U(25),V(""),J(""),await eC()}catch(e){I(e.message)}},e_=async(e,t)=>{try{let r=ew[e]||void 0,s=await fetch(`/api/session-requests/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,message:r})}),a=await s.json();if(!s.ok)throw Error(a.error||"Failed to respond");ek(t=>({...t,[e]:""})),await eC()}catch(e){I(e.message)}},eF=async e=>{try{let t=await fetch(`/api/session-requests/${e}`,{method:"DELETE"}),r=await t.json().catch(()=>({}));if(!t.ok)throw Error(r.error||"Failed to delete");await eC()}catch(e){I(e.message)}},eE=e=>{"text"===e.type&&(er(e.id),ea(e.content??""))},eI=async t=>{let r=es.trim();if(!r)return void I("Message cannot be empty");ei(e=>new Set(e).add(t));try{let s=await fetch(`/api/chat/${e}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to edit message");D(e=>e.map(e=>e.id===t?{...e,content:r,edited_at:new Date().toISOString(),deleted:!1}:e)),er(null),ea("")}catch(e){I(e.message)}finally{ei(e=>{let r=new Set(e);return r.delete(t),r})}},eT=async t=>{ei(e=>new Set(e).add(t));try{let r=await fetch(`/api/chat/${e}/${t}`,{method:"DELETE"}),s=await r.json().catch(()=>({}));if(!r.ok)throw Error(s.error||"Failed to delete message");D(e=>e.map(e=>e.id===t?{...e,content:"[This message was deleted]",deleted:!0,deleted_at:new Date().toISOString(),edited_at:null}:e)),et===t&&(er(null),ea(""))}catch(e){I(e.message)}finally{ei(e=>{let r=new Set(e);return r.delete(t),r})}},eA=e=>{if("text"===e.type){let t=et===e.id;return(0,s.jsx)("div",{children:t?(0,s.jsxs)("div",{className:"flex flex-col gap-2 min-w-[220px]",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider font-medium text-rf-on-primary/70",children:[(0,s.jsx)("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-rf-peach"}),"Editing message"]}),(0,s.jsx)("textarea",{autoFocus:!0,value:es,onChange:e=>ea(e.target.value),onKeyDown:t=>{"Enter"!==t.key||t.shiftKey?"Escape"===t.key&&(t.preventDefault(),er(null),ea("")):(t.preventDefault(),eI(e.id))},rows:Math.min(6,Math.max(2,es.split("\n").length)),className:"w-full resize-none rounded-xl bg-rf-on-primary/15 px-3 py-2 text-sm text-rf-on-primary placeholder:text-rf-on-primary/60 ring-1 ring-inset ring-rf-on-primary/15 focus:outline-none focus:ring-rf-on-primary/40 focus:bg-rf-on-primary/20 transition-colors",placeholder:"Edit your message…"}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"text-[10px] text-rf-on-primary/60 hidden sm:inline",children:"Enter to save \xb7 Esc to cancel"}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1.5",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{er(null),ea("")},disabled:en.has(e.id),className:"rounded-full px-3 py-1 text-[11px] font-medium text-rf-on-primary/80 hover:text-rf-on-primary hover:bg-rf-on-primary/10 disabled:opacity-60 transition-colors",children:"Cancel"}),(0,s.jsx)("button",{type:"button",onClick:()=>eI(e.id),disabled:en.has(e.id)||!es.trim()||es.trim()===(e.content??"").trim(),className:"rounded-full bg-rf-on-primary px-3 py-1 text-[11px] font-semibold text-rf-primary hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:en.has(e.id)?"Saving…":"Save"})]})]})]}):(0,s.jsx)("div",{className:`whitespace-pre-wrap break-words text-sm leading-5 ${e.deleted?"italic opacity-80":""}`,children:e.content})})}if("session-request"===e.type){let t=e.payload||void 0,r=(t?.from_user_id??e.from_user_id
1)===T;return(0,s.jsxs)("div",{className:"text-sm",children:[(0,s.jsx)("div",{className:`rounded-md border inline-flex items-center gap-2 px-2 py-1 text-xs font-medium ${t?.status==="accepted"?"bg-rf-cream-bg text-rf-plum-ink border-rf-peach":t?.status==="declined"?"bg-red-100 text-red-700 border-red-200":t?.status==="cancelled"?"bg-rf-line-soft text-rf-ink-soft border-rf-line":"bg-amber-50 text-amber-700 border-amber-200"}`,children:"Session request"}),(0,s.jsxs)("div",{className:"mt-1 text-sm",children:[new Date(t?.start??"").toLocaleString()," \xb7 ",t?.durationMin," min",t?.message?(0,s.jsxs)("span",{className:"ml-2 italic",children:["“",t.message,"”"]}):null,t?.goal?(0,s.jsxs)("div",{className:"mt-1 text-xs text-rf-plum-ink bg-rf-cream-bg px-2 py-1 rounded",children:[(0,s.jsx)("strong",{children:"Goal:"})," ",t.goal]}):null]}),t?.status==="pending"?(0,s.jsx)("div",{className:"mt-2 flex items-center gap-2",children:r?(0,s.jsx)("button",{onClick:()=>{t?.sessionRequestId&&eF(t.sessionRequestId)},className:"rounded-md bg-rf-line px-3 py-1 text-xs font-medium text-rf-ink-soft hover:bg-rf-line",children:"Delete request"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"text",placeholder:"Optional message",className:"w-44 rounded border px-2 py-1 text-xs",value:ew[t?.sessionRequestId??""]||"",onChange:e=>ek(r=>({...r,[t?.sessionRequestId??""]:e.target.value}))}),(0,s.jsx)("button",{onClick:()=>{t?.sessionRequestId&&e_(t.sessionRequestId,"accept")},className:"rounded-md bg-rf-primary px-3 py-1 text-xs font-medium text-rf-on-primary hover:bg-rf-primary-hover",children:"Accept"}),(0,s.jsx)("button",{onClick:()=>{t?.sessionRequestId&&e_(t.sessionRequestId,"decline")},className:"rounded-md bg-red-600 px-3 py-1 text-xs font-medium text-white hover:bg-red-700",children:"Decline"})]})}):(0,s.jsxs)("div",{className:"mt-2 text-xs text-rf-ink-mute capitalize",children:["Status: ",t?.status]})]})}return(0,s.jsx)("div",{className:"text-xs text-rf-ink-mute",children:"Unsupported message"})},eq="modal"===b,eM=t?.[0]?.toUpperCase?.()||"F",eO=e=>{let t=e?N:r,a=e?v?.user?.name?.[0]?.toUpperCase()??"Y":eM,n=eq?"h-7 w-7":"h-6 w-6",i=eq?"text-xs":"text-[10px]";return(0,s.jsxs)(m.Avatar,{className:`${n} shrink-0`,children:[t?(0,s.jsx)(m.AvatarImage,{src:t,alt:""}):null,(0,s.jsx)(m.AvatarFallback,{className:`${i} font-semibold ${e?"bg-rf-primary text-rf-on-primary":"bg-rf-cream-bg text-rf-plum-ink"}`,children:a})]})},eL=(0,s.jsxs)("div",{className:`flex items-center justify-between border-b border-rf-line/70 bg-rf-card/95 backdrop-blur-sm ${eq?"px-5 py-4":"px-3 h-10"}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,s.jsxs)(m.Avatar,{className:`shrink-0 ${eq?"h-10 w-10":"h-6 w-6"}`,children:[r?(0,s.jsx)(m.AvatarImage,{src:r,alt:t}):null,(0,s.jsx)(m.AvatarFallback,{className:`font-semibold bg-rf-cream-bg text-rf-plum-ink ${eq?"text-sm":"text-[10px]"}`,children:eM})]}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:`inline-flex max-w-full min-w-0 items-center gap-1.5 font-semibold text-rf-ink truncate ${eq?"text-base max-w-[260px]":"text-sm max-w-[200px]"}`,children:[(0,s.jsx)("span",{className:"truncate",children:t}),h?(0,s.jsx)(u.g,{size:"xs"}):null]}),eq&&(0,s.jsx)("div",{className:"text-xs text-rf-ink-mute",children:"Direct message"})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[w?(0,s.jsx)("button",{onClick:w,"aria-label":y?"Maximize chat":"Minimize chat",className:`inline-flex items-center justify-center rounded-md text-rf-ink-mute hover:text-rf-ink hover:bg-rf-line-soft transition-colors ${eq?"h-8 w-8":"h-6 w-6"}`,children:y?(0,s.jsx)(n.mkN,{size:eq?16:14}):(0,s.jsx)(n.QLg,{size:eq?16:14})}):null,(0,s.jsx)("button",{onClick:g,"aria-label":"Close chat",className:`inline-flex items-center justify-center rounded-md text-rf-ink-mute hover:text-rf-ink hover:bg-rf-line-soft transition-colors ${eq?"h-8 w-8":"h-6 w-6"}`,children:(0,s.jsx)(n.yGN,{size:eq?16:14})})]})]}),eR=(0,s.jsxs)(s.Fragment,{children:[E&&(0,s.jsx)("div",{className:"mx-3 mt-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300",children:E}),(0,s.jsx)("div",{ref:ej,className:`flex flex-1 flex-col overflow-y-auto ${eq?"px-5 py-4":"p-3"} ${"docked"===b?"min-h-0":""} bg-gradient-to-b from-white to-[#FFF7E6]/40 dark:from-gray-900 dark:to-gray-900`,onScroll:eS,children:_&&0===$.length?(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center text-xs text-rf-ink-mute",children:"Loading…"}):0===$.length?(0,s.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center text-center px-6",children:[r?(0,s.jsxs)(m.Avatar,{className:`${eq?"h-14 w-14 mb-4":"h-10 w-10 mb-3"}`,children:[(0,s.jsx)(m.AvatarImage,{src:r,alt:t}),(0,s.jsx)(m.AvatarFallback,{className:`font-semibold bg-rf-cream-bg text-rf-plum-ink ${eq?"text-lg":"text-sm"}`,children:eM})]}):(0,s.jsx)("div",{className:`flex items-center justify-center rounded-full bg-rf-cream-bg ${eq?"h-14 w-14 mb-4":"h-10 w-10 mb-3"}`,children:(0,s.jsx)(n.X6_,{className:`text-rf-plum-ink ${eq?"w-6 h-6":"w-5 h-5"}`})}),(0,s.jsxs)("p",{className:`font-semibold text-rf-ink ${eq?"text-base":"text-sm"}`,children:["Say hi to ",t.split(/[@\s]/)[0]||"your friend"]}),(0,s.jsx)("p",{className:`mt-1 max-w-[260px] text-rf-ink-mute ${eq?"text-sm":"text-xs"}`,children:"Start the conversation, or send a session request to focus together."})]}):(0,s.jsx)("div",{className:"flex flex-col gap-1.5",children:(()=>{let e=[],t=null;for(let r of $){let a=new Date(r.created_at),i=a.toDateString();i!==t&&(e.push((0,s.jsx)("div",{className:"flex items-center justify-center py-2",children:(0,s.jsx)("span",{className:"rounded-full bg-rf-line-soft px-3 py-0.5 text-[10px] font-medium uppercase tracking-wider text-rf-ink-mute",children:ef(a
1)})},`sep-${i}-${r.id}`)),t=i);let l=!!T&&r.from_user_id===T,o=et===r.id,d=l&&"text"===r.type&&!r.deleted&&!o,c=!l&&"text"===r.type&&!r.deleted&&!o,u=d||c,m=el===r.id;e.push((0,s.jsxs)("div",{className:`group flex items-end gap-1.5 ${l?"flex-row-reverse":""}`,children:[eO(l),u&&(0,s.jsxs)("div",{className:`relative ${l?"order-first":""}`,"data-chat-message-menu":!0,children:[(0,s.jsx)("button",{type:"button","aria-label":"Message options",onClick:()=>eo(e=>e===r.id?null:r.id),className:`inline-flex h-7 w-7 items-center justify-center rounded-full text-rf-ink-mute hover:bg-rf-line-soft hover:text-rf-ink transition-opacity opacity-100 lg:opacity-0 lg:group-hover:opacity-100 focus:opacity-100 ${m?"opacity-100":""}`,children:(0,s.jsx)(n.$Ri,{size:14})}),m&&(0,s.jsxs)("div",{className:`absolute top-1/2 z-10 min-w-[112px] -translate-y-1/2 rounded-lg border border-rf-line bg-rf-card py-1 shadow-lg ${l?"right-full mr-1":"left-full ml-1"}`,children:[d?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",onClick:()=>{eo(null),eE(r)},disabled:en.has(r.id),className:"block w-full px-3 py-1.5 text-left text-xs text-rf-ink-soft hover:bg-rf-line-soft disabled:opacity-60",children:"Edit"}),(0,s.jsx)("button",{type:"button",onClick:()=>{eo(null),eT(r.id)},disabled:en.has(r.id),className:"block w-full px-3 py-1.5 text-left text-xs text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-60",children:"Delete"})]}):null,c?(0,s.jsx)("button",{type:"button",onClick:()=>{eo(null),ec(r)},className:"block w-full px-3 py-1.5 text-left text-xs text-rf-ink-soft hover:bg-rf-line-soft",children:"Report"}):null]})]}),(0,s.jsxs)("div",{className:`rounded-2xl px-3 py-2 shadow-sm ${o?"w-[88%] sm:w-[420px]":"max-w-[78%]"} ${l?"bg-rf-primary text-rf-on-primary rounded-br-md":"bg-rf-bubble text-rf-ink rounded-bl-md"}`,children:[eA(r),!o&&(0,s.jsxs)("div",{className:`mt-1 flex items-center justify-end gap-1 text-[10px] ${l?"text-[#FFF1D3]/70":"text-rf-ink-mute"}`,children:[ex(r.created_at),r.edited_at&&!r.deleted?(0,s.jsx)("span",{className:"opacity-80",children:"\xb7 edited"}):null]})]})]},r.id))}return e})()})}),q&&(0,s.jsxs)("div",{className:`shrink-0 border-t border-rf-line/70 bg-rf-bg overflow-y-auto overflow-x-hidden space-y-3 ${"docked"===b?"max-h-[200px] p-2":"max-h-[55%] px-5 py-4"}`,children:[(0,s.jsxs)("div",{className:"docked"===b?"space-y-1":"",children:[(0,s.jsx)("label",{className:"text-[10px] font-medium text-rf-ink-mute uppercase tracking-wide mb-1.5 block",children:"Pick a day"}),(0,s.jsx)("div",{className:"flex gap-1 overflow-x-auto pb-1",children:eg.map((e,t)=>(0,s.jsx)("button",{onClick:()=>{L(e.date),null!==R&&ey(e.date,R)&&P(null)},className:`shrink-0 px-2.5 py-1.5 rounded-md text-xs font-medium transition-colors ${O?.toDateString()===e.date.toDateString()?"bg-rf-primary text-rf-on-primary":"bg-rf-card text-rf-ink-soft hover:bg-rf-line-soft border border-rf-line"}`,children:e.label},t))})]}),O&&(0,s.jsxs)("div",{className:"docked"===b?"space-y-1":"",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("label",{className:"text-[10px] font-medium text-rf-ink-mute uppercase tracking-wide",children:"Pick a time"}),Z&&(0,s.jsx)("span",{className:"text-[10px] text-rf-ink-mute",children:"Checking..."})]}),"docked"!==b&&(0,s.jsxs)("div",{className:"flex gap-3 mb-2 text-[10px]",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-400"}),(0,s.jsx)("span",{className:"text-rf-ink-mute",children:"You're busy"})]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-orange-400"}),(0,s.jsx)("span",{className:"text-rf-ink-mute",children:"Friend busy"})]})]}),(0,s.jsx)("div",{className:"grid gap-1 grid-cols-6",children:eb.map(e=>{let t=ey(O,e.hour),r=eh(O,e.hour,0,Y),a=t||r.hasConflict;return(0,s.jsx)("button",{onClick:()=>!a&&P(e.hour),disabled:a,title:r.isMine&&r.isFriend?"Both of you are busy":r.isMine?"You have a session":r.
1isFriend?"Friend has a session":void 0,className:`relative rounded font-medium transition-colors ${"docked"===b?"px-1 py-1 text-[10px]":"px-1.5 py-1.5 text-[11px]"} ${t?"bg-rf-line-soft text-rf-ink-mute cursor-not-allowed":r.hasConflict?r.isMine?"bg-red-100 dark:bg-red-900/30 text-red-400 dark:text-red-400 cursor-not-allowed border border-red-200 dark:border-red-800":"bg-orange-100 dark:bg-orange-900/30 text-orange-400 dark:text-orange-400 cursor-not-allowed border border-orange-200 dark:border-orange-800":R===e.hour?"bg-rf-primary text-rf-on-primary":"bg-rf-card text-rf-ink-soft hover:bg-rf-line-soft border border-rf-line"}`,children:e.label},e.hour)})}),null!==R&&(0,s.jsxs)("div",{className:`flex items-center gap-2 ${"docked"===b?"mt-1":"mt-2"}`,children:[(0,s.jsx)("span",{className:`text-rf-ink-mute ${"docked"===b?"text-[10px]":"text-xs"}`,children:"Minutes:"}),(0,s.jsx)("div",{className:"flex gap-1",children:x.U1.map(e=>{let t=eh(O,R,e,Y);return(0,s.jsxs)("button",{onClick:()=>!t.hasConflict&&H(e),disabled:t.hasConflict,title:t.isMine&&t.isFriend?"Both busy":t.isMine?"You have a session":t.isFriend?"Friend has a session":void 0,className:`px-2 py-1 rounded text-[11px] font-medium transition-colors ${t.hasConflict?t.isMine?"bg-red-100 dark:bg-red-900/30 text-red-400 cursor-not-allowed":"bg-orange-100 dark:bg-orange-900/30 text-orange-400 cursor-not-allowed":z===e?"bg-rf-primary text-rf-on-primary":"bg-rf-card text-rf-ink-soft hover:bg-rf-line-soft border border-rf-line"}`,children:[":",e.toString().padStart(2,"0")]},e)})})]})]}),O&&null!==R&&(0,s.jsxs)("div",{className:"docked"===b?"space-y-1":"",children:[(0,s.jsx)("label",{className:"text-[10px] font-medium text-rf-ink-mute uppercase tracking-wide mb-1.5 block",children:"Duration"}),(0,s.jsx)("div",{className:"flex gap-1",children:[25,50,75].map(e=>{let t=eh(O,R,z,e);return(0,s.jsxs)("button",{onClick:()=>!t.hasConflict&&U(e),disabled:t.hasConflict,title:t.hasConflict?`${e} min would overlap with ${t.isMine?"your":"friend's"} session`:void 0,className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${t.hasConflict?t.isMine?"bg-red-100 dark:bg-red-900/30 text-red-400 cursor-not-allowed border border-red-200 dark:border-red-800":"bg-orange-100 dark:bg-orange-900/30 text-orange-400 cursor-not-allowed border border-orange-200 dark:border-orange-800":Y===e?"bg-rf-primary text-rf-on-primary":"bg-rf-card text-rf-ink-soft hover:bg-rf-line-soft border border-rf-line"}`,children:[e," min"]},e)})})]}),O&&null!==R&&(0,s.jsxs)("div",{className:"docked"===b?"space-y-1":"mt-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("label",{className:"text-[10px] font-medium text-rf-ink-mute uppercase tracking-wide",children:"Session Goal"}),(0,s.jsx)("button",{type:"button",onClick:ep,disabled:W||!G.trim(),className:"text-[10px] font-medium text-rf-plum-ink hover:text-rf-plum-ink disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1",children:W?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"animate-spin",children:"✦"})," Refining..."]}):(0,s.jsx)(s.Fragment,{children:"✦ AI Refine"})})]}),(0,s.jsx)("textarea",{placeholder:"What specifically do you want to accomplish?",className:"w-full rounded-md border border-rf-line bg-rf-card text-rf-ink px-3 py-2 text-xs placeholder:text-rf-ink-mute min-h-[38px] resize-y",value:G,onChange:e=>J(e.target.value)})]}),O&&null!==R&&(k=eh(O,R,z,Y),(0,s.jsx)("div",{className:"space-y-2",children:k.hasConflict?(0,s.jsx)("div",{className:`p-2 rounded-md text-xs ${k.isMine?"bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400":"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400"}`,children:k.isMine&&k.isFriend?"⚠️ Both of you have sessions during this time":k.isMine?"⚠️ You have a session during this time":"⚠️ Your friend has a session during this time"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"text",placeholder:"Add a message (optional)",maxLength:500,className:"w-full rounded-md border border-rf-line bg-rf-card text-rf-ink px-3 py-2 text-xs placeholder:text-rf-ink-mute",value:B,onChange:e=>V(e.target.value)}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"text-xs text-rf-ink-soft",children:[(0,s.jsx)("span",{className:"text-rf-plum-ink",children:"✓ Both available"}
1)," \xb7 ",((j=new Date(O)).setHours(R,z,0,0),j.toLocaleString(void 0,{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}))," ","\xb7 ",Y," min"]}),(0,s.jsx)("button",{onClick:eD,className:"rounded-md bg-rf-primary hover:bg-rf-primary-hover px-4 py-2 text-xs font-medium text-rf-on-primary transition-colors",children:"Send Request"})]})]})})),(0,s.jsx)("button",{onClick:()=>{M(!1),L(null),P(null),H(0)},className:"w-full text-center text-xs text-rf-ink-mute hover:text-rf-ink py-1",children:"Cancel"})]}),(0,s.jsx)(f,{canInteract:S,verifyMessage:C??null,friendLabel:t,isModal:eq,srOpen:q,setSrOpen:M,onSend:e$})]});return"docked"===b?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:`flex w-[320px] h-[380px] min-w-[300px] min-h-[320px] flex-col overflow-hidden rounded-xl bg-rf-card shadow-2xl border border-rf-line animate-[slide-up_180ms_ease-out] ${y?"h-10":""}`,style:{transformOrigin:"bottom left"},children:[eL,y?(0,s.jsx)("div",{className:"hidden"}):eR]}),ed?(0,s.jsx)(c.A,{open:!0,onClose:()=>ec(null),targetType:"friend_message",targetId:ed.id,reportedUserId:ed.from_user_id,reportedLabel:t,contentPreview:ed.content??void 0}):null]}):"fullscreen"===b?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex h-full w-full flex-col overflow-hidden bg-rf-card",children:[eL,eR]}),ed?(0,s.jsx)(c.A,{open:!0,onClose:()=>ec(null),targetType:"friend_message",targetId:ed.id,reportedUserId:ed.from_user_id,reportedLabel:t,contentPreview:ed.content??void 0}):null]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",children:(0,s.jsxs)("div",{className:"flex w-full max-w-lg h-[600px] max-h-[85vh] flex-col overflow-hidden rounded-2xl bg-rf-card shadow-2xl ring-1 ring-rf-line animate-[scale-in_180ms_ease-out]",style:{transformOrigin:"center"},children:[eL,eR]})}),ed?(0,s.jsx)(c.A,{open:!0,onClose:()=>ec(null),targetType:"friend_message",targetId:ed.id,reportedUserId:ed.from_user_id,reportedLabel:t,contentPreview:ed.content??void 0}):null]})}},38410:(e,t,r)=>{r.d(t,{A:()=>d});var s=r(95155),a=r(12115),n=r(33210),i=r(6296);let l=["harassment","spam","inappropriate","threats","other"],o={harassment:"Harassment or bullying",spam:"Spam or scam",inappropriate:"Inappropriate content",threats:"Threats or violence",other:"Other"};function d({open:e,onClose:t,targetType:r,targetId:c,reportedUserId:u,reportedLabel:m,contentPreview:f,onSuccess:x}){let[p,h]=(0,a.useState)("harassment"),[g,b]=(0,a.useState)(""),[y,w]=(0,a.useState)(!1),[k,j]=(0,a.useState)(null),[v,N]=(0,a.useState)(!1);if(!e)return null;let S=()=>{y||(j(null),N(!1),b(""),h("harassment"),t())},C=async()=>{w(!0),j(null);try{let e=await fetch("/api/reports",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetType:r,targetId:c,reason:p,details:g.trim()||void 0,reportedUserId:u})}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Failed to submit report");N(!0),x?.(),setTimeout(S,1200)}catch(e){j(e.message)}finally{w(!1)}};return(0,s.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4",children:(0,s.jsxs)("div",{className:"w-full max-w-md rounded-xl border border-rf-line bg-rf-card shadow-xl",role:"dialog","aria-modal":"true","aria-labelledby":"report-dialog-title",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between border-b border-rf-line px-4 py-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h2",{id:"report-dialog-title",className:"text-base font-semibold text-rf-ink",children:["Report ",m||"content"]}),(0,s.jsx)("p",{className:"mt-0.5 text-xs text-rf-ink-mute",children:"Our team will review this report."})]}),(0,s.jsx)("button",{type:"button",onClick:S,disabled:y,className:"rounded-lg p-1 text-rf-ink-mute hover:bg-rf-line-soft hover:text-rf-ink","aria-label":"Close",children:(0,s.jsx)(n.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:"space-y-4 p-4",children:[f?(0,s.jsxs)("div",{className:"rounded-lg bg-rf-bg px-3 py-2 text-xs text-rf-ink-soft",children:[(0,s.jsx)("p",{className:"mb-1 font-medium text-rf-ink-mute",children:"Preview"}),(0,s.jsx)("p",{className:"whitespace-pre-wrap break-words",children:f})]}):null,v?(0,s.jsx)("p",{className:"text-sm text-green-600 dark:text-green-400",children:"Thanks — we'll review this report."}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("fieldset",{className:"space-y-2",children:[(0,s.jsx)("legend",{className:"text-xs font-medium uppercase tracking-wide text-rf-ink-mute",children:"Reason"}),l.map(e=>(0,s.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg border border-rf-line px-3 py-2 text-sm has-[:checked]:border-[#5D1C6A] has-[:checked]:bg-[#5D1C6A]/5",children:[(0,s.jsx)("input",{type:"radio",name:"report-reason",value:e,checked:p===e,onChange:()=>h(e),className:"accent-rf-primary"}),(0,s.jsx)("span",{className:"text-rf-ink",children:o[e]})]},e))]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"report-details",className:"text-xs font-medium uppercase tracking-wide text-rf-ink-mute",children:"Additional details (optional)"}),(0,s.jsx)("textarea",{id:"report-details",value:g,onChange:e=>b(e.target.value),rows:3,maxLength:500,placeholder:"Anything else we should know?",className:"mt-1.5 w-full rounded-lg border border-rf-line bg-rf-card px-3 py-2 text-sm text-rf-ink placeholder:text-rf-ink-mute"})]}),k?(0,s.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:k}):null]})]}),v?null:(0,s.jsxs)("div",{className:"flex justify-end gap-2 border-t border-rf-line px-4 py-3",children:[(0,s.jsx)("button",{type:"button",onClick:S,disabled:y,className:"rounded-lg border border-rf-line px-4 py-2 text-sm font-medium text-rf-ink-soft hover:bg-rf-line-soft",children:"Cancel"}),(0,s.jsxs)("button",{type:"button",onClick:C,disabled:y,className:"inline-flex items-center gap-2 rounded-lg bg-rf-primary px-4 py-2 text-sm font-medium text-rf-on-primary hover:bg-rf-primary-hover disabled:opacity-50",children:[y?(0,s.jsx)(i.A,{className:"h-4 w-4 animate-spin"}):null,"Submit report"]})]})]})})}},40048:(e,t,r)=>{r.d(t,{c:()=>a});var s=r(12115);
1function a(){let[e,t]=(0,s.useState)(null),r=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/users/me");if(!e.ok)return void t(null);let r=await e.json();t(!!r?.user?.emailVerified)}catch{t(null)}},[]);return(0,s.useEffect)(()=>{r()},[r]),{verified:e,loading:null===e,canInteract:!1!==e,message:"Verify your email to use this feature. You can browse until then.",refresh:r}}},77189:(e,t,r)=>{r.d(t,{Hj:()=>i,d0:()=>l,ur:()=>o});var s=r(44855),a=r(12115),n=r(2665);function i(){let e=(0,s.Ay)(n.D.friendsIncoming),t=(0,s.Ay)(n.D.friendsOutgoing),r=(0,s.Ay)(n.D.friends),i=(0,s.Ay)(n.D.sessionRequestsIncoming),l=(0,s.Ay)(n.D.sessionRequestsOutgoing),o=(0,s.Ay)(n.D.chatUnreadCounts),{mutate:d}=o,c=(0,a.useMemo)(()=>o.data?.counts??{},[o.data?.counts]),u=(0,a.useCallback)(e=>{d(t=>{let r=t?.counts??{};return{counts:"function"==typeof e?e(r):e}},{revalidate:!1})},[d]),m=(0,a.useCallback)(async()=>{await Promise.all([e.mutate(),t.mutate(),r.mutate(),i.mutate(),l.mutate(),o.mutate()]);try{window.dispatchEvent(new CustomEvent("friends:session-requests-updated"))}catch{}},[e,t,r,i,l,o]),f=null==r.data&&null==e.data&&null==t.data&&null==i.data&&null==l.data&&(r.isLoading||e.isLoading||t.isLoading||i.isLoading||l.isLoading),x=r.error||e.error||t.error||i.error||l.error;return{incoming:e.data?.requests??[],outgoing:t.data?.requests??[],friends:r.data?.friends??[],sessIncoming:i.data?.requests??[],sessOutgoing:l.data?.requests??[],unreadCounts:c,setUnreadCounts:u,loading:f,isValidating:r.isValidating||e.isValidating||t.isValidating||i.isValidating||l.isValidating,error:x?x.message:null,refresh:m,mutateFriends:r.mutate}}function l(){let{data:e,error:t,isLoading:r,isValidating:a,mutate:i}=(0,s.Ay)(n.D.friends);return{friends:e?.friends??[],loading:r&&null==e,loaded:null!=e,isValidating:a,error:t?t.message:null,refresh:i}}function o(){let{data:e,mutate:t}=(0,s.Ay)(n.D.sessionRequestsIncoming);return{count:e?.requests?.length??0,refresh:t}}}}]);

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.