PageSourceSearch

https://app.golfwa.com/assets/Buddies-BvIwCJGM.js

js golfwa.com collected 2026-10-10 02:26:41 UTC 24,145 bytes, 6 lines download raw bytes

1import{i as Ie,r as c,j as e,ac as J,ae as G,af as T,ah as Z,ay as Ce,ag as Te,az as ee,ab as te,aA as Re,a7 as Y,e as L,I as Fe,H as z,g as F,h as w,X as ke,p as se,L as qe,F as H,G as Ee,U as Ge,aB as Me}from"./index-CIN_kJ-x.js";import{P as Pe}from"./index-Txu8YiX7.js";import{D as P,S as Ae,a as Be,b as ae}from"./avatars--AiidWtr.js";import{S as De}from"./search-BHrFqc3V.js";import{C as re}from"./clock-DyKGwywg.js";import{U as Le}from"./user-plus-u6JxW7BU.js";import{T as W}from"./textarea-D10HqbTl.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Ke=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],Oe=Ie("Inbox",Ke);var U="rovingFocusGroup.onEntryFocus",Ue={bubbles:!1,cancelable:!0},A="RovingFocusGroup",[V,ne,ze]=Ce(A),[Ve,oe]=Z(A,[ze]),[Ye,$e]=Ve(A),ie=c.forwardRef((t,o)=>e.jsx(V.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(V.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Qe,{...t,ref:o})})}));
6ie.displayName=A;var Qe=c.forwardRef((t,o)=>{const{__scopeRovingFocusGroup:r,orientation:i,loop:u=!1,dir:m,currentTabStopId:a,defaultCurrentTabStopId:n,onCurrentTabStopIdChange:b,onEntryFocus:x,preventScrollOnEntryFocus:l=!1,...h}=t,v=c.useRef(null),_=Te(o,v),N=ee(m),[S,g]=te({prop:a,defaultProp:n??null,onChange:b,caller:A}),[d,f]=c.useState(!1),s=Re(x),j=ne(r),p=c.useRef(!1),[I,C]=c.useState(0);return c.useEffect(()=>{const y=v.current;if(y)return y.addEventListener(U,s),()=>y.removeEventListener(U,s)},[s]),e.jsx(Ye,{scope:r,orientation:i,dir:N,loop:u,currentTabStopId:S,onItemFocus:c.useCallback(y=>g(y),[g]),onItemShiftTab:c.useCallback(()=>f(!0),[]),onFocusableItemAdd:c.useCallback(()=>C(y=>y+1),[]),onFocusableItemRemove:c.useCallback(()=>C(y=>y-1),[]),children:e.jsx(G.div,{tabIndex:d||I===0?-1:0,"data-orientation":i,...h,ref:_,style:{outline:"none",...t.style},onMouseDown:T(t.onMouseDown,()=>{p.current=!0}),onFocus:T(t.onFocus,y=>{const O=!p.current;if(y.target===y.currentTarget&&O&&!d){const B=new CustomEvent(U,Ue);if(y.currentTarget.dispatchEvent(B),!B.defaultPrevented){const M=j().filter(k=>k.focusable),D=M.find(k=>k.active),R=M.find(k=>k.id===S),Se=[D,R,...M].filter(Boolean).map(k=>k.ref.current);le(Se,l)}}p.current=!1}),onBlur:T(t.onBlur,()=>f(!1))})})}),de="RovingFocusGroupItem",ce=c.forwardRef((t,o)=>{const{__scopeRovingFocusGroup:r,focusable:i=!0,active:u=!1,tabStopId:m,children:a,...n}=t,b=J(),x=m||b,l=$e(de,r),h=l.currentTabStopId===x,v=ne(r),{onFocusableItemAdd:_,onFocusableItemRemove:N,currentTabStopId:S}=l;return c.useEffect(()=>{if(i)return _(),()=>N()},[i,_,N]),e.jsx(V.ItemSlot,{scope:r,id:x,focusable:i,active:u,children:e.jsx(G.span,{tabIndex:h?0:-1,"data-orientation":l.orientation,...n,ref:o,onMouseDown:T(t.onMouseDown,g=>{i?l.onItemFocus(x):g.preventDefault()}),onFocus:T(t.onFocus,()=>l.onItemFocus(x)),onKeyDown:T(t.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){l.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const d=Xe(g,l.orientation,l.dir);if(d!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let s=v().filter(j=>j.focusable).map(j=>j.ref.current);if(d==="last")s.reverse();else if(d==="prev"||d==="next"){d==="prev"&&s.reverse();const j=s.indexOf(g.currentTarget);s=l.loop?Je(s,j+1):s.slice(j+1)}setTimeout(()=>le(s))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:S!=null}):a})})});ce.displayName=de;var He={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function We(t,o){return o!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Xe(t,o,r){const i=We(t.key,r);if(!(o==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(o==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return He[i]}function le(t,o=!1){const r=document.activeElement;for(const i of t)if(i===r||(i.focus({preventScroll:o}),document.activeElement!==r))return}function Je(t,o){return t.map((r,i)=>t[(o+i)%t.length])}var Ze=ie,et=ce,K="Tabs",[tt]=Z(K,[oe]),ue=oe(),[st,$]=tt(K),me=c.forwardRef((t,o)=>{const{__scopeTabs:r,value:i,onValueChange:u,defaultValue:m,orientation:a="horizontal",dir:n,activationMode:b="automatic",...x}=t,l=ee(n),[h,v]=te({prop:i,onChange:u,defaultProp:m??"",caller:K});return e.jsx(st,{scope:r,baseId:J(),value:h,onValueChange:v,orientation:a,dir:l,activationMode:b,children:e.jsx(G.div,{dir:l,"data-orientation":a,...x,ref:o})})});me.displayName=K;var xe="TabsList",pe=c.forwardRef((t,o)=>{const{__scopeTabs:r,loop:i=!0,...u}=t,m=$(xe,r),a=ue(r);return e.jsx(Ze,{asChild:!0,...a,orientation:m.orientation,dir:m.dir,loop:i,children:e.jsx(G.div,{role:"tablist","aria-orientation":m.orientation,...u,ref:o})})});pe.displayName=xe;var fe="TabsTrigger",he=c.forwardRef((t,o)=>{const{__scopeTabs:r,value:i,disabled:u=!1,...m}=t,a=$(fe,r),n=ue(r),b=ve(a.baseId,i),x=ye(a.baseId,i),l=i===a.value;return e.jsx(et,{asChild:!0,...n,focusable:!u,active:l,children:e.jsx(G.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":x,"data-state":l?"active":"inactive","data-disabled":u?"":void 0,disabled:u,id:b,...m,ref:o,onMouseDown:T(t.onMouseDown,h=>{!u&&h.button===0&&h.ctrlKey===!1?a.onValueChange(i):h.preventDefault()}),onKeyDown:T(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&a.onValueChange(i)}),onFocus:T(t.onFocus,()=>{const h=a.activationMode!=="manual";!l&&!u&&h&&a.onValueChange(i)})})})});he.displayName=fe;var ge="TabsContent",be=c.forwardRef((t,o)=>{const{__scopeTabs:r,value:i,forceMount:u,children:m,...a}=t,n=$(ge,r),b=ve(n.baseId,i),x=ye(n.baseId,i),l=i===n.value,h=c.useRef(l);return c.useEffect(()=>{const v=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(v)},[]),e.jsx(Pe,{present:u||l,children:({present:v})=>e.jsx(G.div,{"data-state":l?"active":"inactive","data-orientation":n.orientation,role:"tabpanel","aria-labelledby":b,hidden:!v,id:x,tabIndex:0,...a,ref:o,style:{...t.style,animationDuration:h.current?"0s":void 0},children:v&&m})})});be.displayName=ge;function ve(t,o){return`${t}-trigger-${o}`}function ye(t,o){return`${t}-content-${o}`}var at=me,je=pe,_e=he,Ne=be;const we=at,Q=c.forwardRef(({className:t,...o},r)=>e.jsx(je,{ref:r,className:Y("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...o}));Q.displayName=je.displayName;const q=c.forwardRef(({className:t,...o},r)=>e.jsx(_e,{ref:r,className:Y("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...o}));q.displayName=_e.displayName;const E=c.forwardRef(({className:t,...o},r)=>e.jsx(Ne,{ref:r,className:Y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...o}));E.displayName=Ne.displayName;function rt({me:t,requests:o,onDone:r}){var g;const[i,u]=c.useState(""),[m,a]=c.useState(null),[n,b]=c.useState(new Set),{data:x,isLoading:l}=L({queryKey:["members"],queryFn:()=>w.functions.invoke("listMembers",{}),staleTime:6e4}),h=((g=x==null?void 0:x.data)==null?void 0:g.members)||[],v=i.trim().toLowerCase(),_=v?h.filter(d=>(d.name||"").toLowerCase().includes(v)):h;function N(d){const f=o.find(s=>s.from_user_id===t.id&&s.to_user_id===d||s.from_user_id===d&&s.to_user_id===t.id);return(f==null?void 0:f.status)==="accepted"?"accepted":(f==null?void 0:f.status)==="pending"&&f.from_user_id===t.id?"pending_mine":(f==null?void 0:f.status)==="pending"&&f.to_user_id===t.id?"pending_theirs":"none"}async function S(d){a(d.id);try{await w.entities.BuddyRequest.create({from_user_id:t.id,from_name:t.display_name||t.full_name||"Golfer",from_avatar:t.profile_image_url||"",to_user_id:d.id,to_name:d.name||"Golfer",to_avatar:d.avatar||"",status:"pending"});try{await w.functions.invoke("sendBuddyRequestEmail",{to_user_id:d.id})}catch{}b(f=>new Set(f).add(d.id)),r==null||r()}finally{a(null)}}return e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-5",children:[e.jsx("h3",{className:"font-heading text-lg font-semibold mb-1",children:"Add a Buddy"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Search members by name and send a buddy request to anyone."}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name…",value:i,onChange:d=>u(d.target.value),className:"pl-9"})]}),e.jsx("div",{className:"mt-4 max-h-80 overflow-y-auto space-y-2 pr-1",children:l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading members…"}):_.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:v?"No members match your search.":"No other members yet."}):_.map(d=>{const f=N(d.id),s=n.has(d.id);return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-xl border border-border",children:[e.jsx("img",{src:d.avatar||P,alt:"",className:"rounded-full object-cover border border-border",style:{width:40,height:40}}),e.jsx("span",{className:"flex-1 min-w-0 text-sm font-medium truncate",children:d.name}),f==="accepted"&&e.jsxs("span",{className:"text-xs text-primary flex items-center gap-1",children:[e.jsx(z,{className:"w-4 h-4"})," Buddies"]}),f==="pending_mine"&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(re,{className:"w-3.5 h-3.5"})," Sent"]}),f==="pending_theirs"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Check Requests"}),f==="none"&&!s&&e.jsxs(F,{size:"sm",variant:"outline",onClick:()=>S(d),disabled:m===d.id,children:[e.jsx(Le,{className:"w-4 h-4"})," ",m===d.id?"Sending":"Request"]}),s&&e.jsxs("span",{className:"text-xs text-primary flex items-center gap-1",children:[e.jsx(z,{className:"w-4 h-4"})," Sent"]})]},d.id)})})]})}function nt({incoming:t,outgoing:o,onAction:r}){async function i(a){await w.entities.BuddyRequest.update(a.id,{status:"accepted"}),r==null||r()}async function u(a){await w.entities.BuddyRequest.update(a.id,{status:"denied"}),r==null||r()}async function m(a){await w.entities.BuddyRequest.delete(a.id),r==null||r()}return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-heading text-lg font-semibold mb-3",children:"Incoming Requests"}),t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No pending requests."}):e.jsx("div",{className:"space-y-3",children:t.map(a=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border border-border bg-card",children:[e.jsx("img",{src:a.from_avatar||P,alt:"",className:"rounded-full object-cover border border-border",style:{width:44,height:44}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:a.from_name||"Golfer"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"wants to be your buddy"})]}),e.jsxs(F,{size:"sm",onClick:()=>i(a),children:[e.jsx(z,{className:"w-4 h-4"})," Accept"]}),e.jsxs(F,{size:"sm",variant:"outline",onClick:()=>u(a),children:[e.jsx(ke,{className:"w-4 h-4"})," Deny"]})]},a.id))})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-heading text-lg font-semibold mb-3",children:"Sent Requests"}),o.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"You haven't sent any requests."}):e.jsx("div",{className:"space-y-3",children:o.map(a=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border border-border bg-card",children:[e.jsx("img",{src:a.to_avatar||P,alt:"",className:"rounded-full object-cover border border-border",style:{width:44,height:44}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:a.to_name||"Golfer"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(re,{className:"w-3 h-3"})," Pending"]})]}),e.jsx(F,{size:"sm",variant:"outline",onClick:()=>m(a),children:"Cancel"})]},a.id))})]})]})}function ot({buddies:t,myPlans:o,me:r,onSent:i}){const[u,m]=c.useState(new Set),[a,n]=c.useState("note"),[b,x]=c.useState(""),[l,h]=c.useState(""),[v,_]=c.useState(!1),[N,S]=c.useState(0),g=p=>{m(I=>{const C=new Set(I);
6return C.has(p)?C.delete(p):C.add(p),C})},d=()=>m(new Set(t.map(p=>p.id))),f=()=>m(new Set),s=u.size>0&&!v&&(a==="note"?b.trim():l);async function j(){var D;const p=t.filter(R=>u.has(R.id));if(!p.length||a==="note"&&!b.trim()||a==="group_plan_share"&&!l)return;_(!0);const I=o.find(R=>R.id===l),C=new Date().toISOString().slice(0,10),y=typeof crypto<"u"&&((D=crypto.randomUUID)==null?void 0:D.call(crypto))||String(Date.now()),O=r.display_name||r.full_name||"Golfer",B=r.profile_image_url||"",M=p.map(R=>({batch_id:y,from_user_id:r.id,from_name:O,from_avatar:B,recipient_id:R.id,recipient_name:R.name||"Golfer",type:a,body:b.trim(),group_plan_id:a==="group_plan_share"?l:"",group_plan_name:a==="group_plan_share"&&(I==null?void 0:I.name)||"",posted_date:C}));try{await w.entities.BuddyMessage.bulkCreate(M),S(p.length),x(""),h(""),m(new Set),i==null||i(),setTimeout(()=>S(0),2500)}finally{_(!1)}}return t.length===0?e.jsx("div",{className:"bg-card border border-border rounded-2xl p-6 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have any buddies yet. Send a request above and accept incoming requests to build your list."})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-heading text-lg font-semibold",children:"Your Buddies"}),e.jsxs("div",{className:"flex gap-2 text-xs",children:[e.jsx("button",{onClick:d,className:"text-primary hover:underline",children:"Select all"}),e.jsx("span",{className:"text-muted-foreground",children:"·"}),e.jsx("button",{onClick:f,className:"text-muted-foreground hover:underline",children:"Clear"})]})]}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-2",children:t.map(p=>{const I=u.has(p.id);return e.jsxs("button",{onClick:()=>g(p.id),className:`flex items-center gap-3 p-2 rounded-xl border transition-colors text-left ${I?"border-primary bg-primary/5":"border-border hover:border-primary/40"}`,children:[I?e.jsx(Ae,{className:"w-4 h-4 text-primary shrink-0"}):e.jsx(Be,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("img",{src:p.avatar||P,alt:"",className:"rounded-full object-cover border border-border",style:{width:36,height:36}}),e.jsx("span",{className:"text-sm font-medium truncate",children:p.name||"Golfer"})]},p.id)})})]}),e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-5",children:[e.jsxs("h3",{className:"font-heading text-lg font-semibold mb-3",children:["Send to ",u.size," ",u.size===1?"buddy":"buddies"]}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsx(F,{size:"sm",variant:a==="note"?"default":"outline",onClick:()=>n("note"),children:"Text Note"}),e.jsx(F,{size:"sm",variant:a==="group_plan_share"?"default":"outline",onClick:()=>n("group_plan_share"),children:"Share Group Outing"})]}),a==="note"?e.jsx(W,{rows:3,placeholder:"Write a note to your buddies…",value:b,onChange:p=>x(p.target.value)}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("select",{value:l,onChange:p=>h(p.target.value),className:"w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm",children:[e.jsx("option",{value:"",children:"Select a Group Outing…"}),o.map(p=>e.jsx("option",{value:p.id,children:p.name},p.id))]}),e.jsx(W,{rows:2,placeholder:"Add an optional message…",value:b,onChange:p=>x(p.target.value)}),o.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"You haven't created any Group Outings yet."})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[e.jsxs(F,{onClick:j,disabled:!s,children:[e.jsx(ae,{className:"w-4 h-4"})," ",v?"Sending…":"Send"]}),N>0&&e.jsxs("span",{className:"text-sm text-primary",children:["Sent to ",N," ",N===1?"buddy":"buddies","!"]})]})]})]})}function X(t){if(!t)return"";try{return new Date(t).toLocaleDateString()}catch{return t}}function it({received:t,sentGroups:o}){const r=se(),[i,u]=c.useState(null);async function m(n){if(confirm("Delete this message?")){u(n);try{await w.entities.BuddyMessage.delete(n),r.invalidateQueries({queryKey:["buddyMessages"]})}finally{u(null)}}}async function a(n){if(confirm("Delete this sent message for all recipients?")){u(n);try{await w.entities.BuddyMessage.deleteMany({batch_id:n}),r.invalidateQueries({queryKey:["buddyMessages"]})}finally{u(null)}}}return e.jsxs(we,{defaultValue:"inbox",children:[e.jsxs(Q,{children:[e.jsxs(q,{value:"inbox",children:[e.jsx(Oe,{className:"w-4 h-4 mr-1"})," Inbox (",t.length,")"]}),e.jsxs(q,{value:"sent",children:[e.jsx(ae,{className:"w-4 h-4 mr-1"})," Sent (",o.length,")"]})]}),e.jsx(E,{value:"inbox",className:"mt-4",children:t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No messages yet. Your buddies can send you notes and Group Outing shares here."}):e.jsx("div",{className:"space-y-3",children:t.map(n=>e.jsxs("div",{className:"flex gap-3 p-4 rounded-xl border border-border bg-card",children:[e.jsx("img",{src:n.from_avatar||P,alt:"",className:"rounded-full object-cover border border-border",style:{width:40,height:40}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"font-medium text-sm",children:n.from_name||"Buddy"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:X(n.posted_date)})]}),n.type==="group_plan_share"&&e.jsxs("p",{className:"text-xs text-primary mt-0.5",children:["Shared a Group Outing: ",n.group_plan_name]}),n.type==="trip_share"&&e.jsxs("p",{className:"text-xs text-primary mt-0.5",children:["Shared a Trip:"," ",e.jsx(qe,{to:`/trips/${n.trip_id}`,className:"underline font-medium",children:n.trip_name})]}),n.body&&e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:n.body})]}),e.jsx("button",{onClick:()=>m(n.id),disabled:i===n.id,className:"p-2 rounded-lg hover:bg-destructive/10 text-muted-foreground hover:text-destructive disabled:opacity-50 shrink-0",title:"Delete message",children:e.jsx(H,{className:"w-4 h-4"})})]},n.id))})}),e.jsx(E,{value:"sent",className:"mt-4",children:o.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"You haven't sent any messages yet."}):e.jsx("div",{className:"space-y-3",children:o.map(n=>e.jsxs("div",{className:"p-4 rounded-xl border border-border bg-card",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",n.recipients]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:X(n.posted_date)}),e.jsx("button",{onClick:()=>a(n.batch_id),disabled:i===n.batch_id,className:"p-1.5 rounded-lg hover:bg-destructive/10 text-muted-foreground hover:text-destructive disabled:opacity-50",title:"Delete sent message",children:e.jsx(H,{className:"w-4 h-4"})})]})]}),n.type==="group_plan_share"&&e.jsxs("p",{className:"text-xs text-primary mt-0.5",children:["Shared Group Outing: ",n.group_plan_name]}),n.type==="trip_share"&&e.jsxs("p",{className:"text-xs text-primary mt-0.5",children:["Shared Trip: ",n.trip_name]}),n.body&&e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:n.body})]},n.batch_id))})})]})}function ht(){const{user:t,navigateToLogin:o}=Ee(),r=se(),[i,u]=c.useState("buddies"),{data:m=[]}=L({queryKey:["buddyRequests"],queryFn:()=>w.entities.BuddyRequest.list("-created_date",200),enabled:!!t}),{data:a=[]}=L({queryKey:["buddyMessages"],queryFn:()=>w.entities.BuddyMessage.list("-created_date",200),enabled:!!t}),{data:n=[]}=L({queryKey:["groupPlansAll"],queryFn:()=>w.entities.GroupPlan.list("-created_date",100),enabled:!!t}),b=()=>{r.invalidateQueries({queryKey:["buddyRequests"]}),r.invalidateQueries({queryKey:["buddyMessages"]})},x=c.useMemo(()=>
6{if(!t)return{incoming:[],outgoing:[],buddies:[],received:[],sentGroups:[],myPlans:[]};const l=m.filter(s=>s.to_user_id===t.id&&s.status==="pending"),h=m.filter(s=>s.from_user_id===t.id&&s.status==="pending"),_=m.filter(s=>s.status==="accepted").map(s=>{const j=s.from_user_id===t.id;return{id:j?s.to_user_id:s.from_user_id,name:j?s.to_name:s.from_name,avatar:j?s.to_avatar:s.from_avatar}}),N=a.filter(s=>s.recipient_id===t.id),S=a.filter(s=>s.from_user_id===t.id),g=[],d={};S.forEach(s=>{d[s.batch_id]||(d[s.batch_id]={batch_id:s.batch_id,recipients:[],type:s.type,body:s.body,group_plan_name:s.group_plan_name,trip_name:s.trip_name,trip_id:s.trip_id,posted_date:s.posted_date},g.push(d[s.batch_id])),d[s.batch_id].recipients.push(s.recipient_name||"Buddy")}),g.forEach(s=>s.recipients=s.recipients.join(", "));const f=n.filter(s=>s.created_by_id===t.id);return{incoming:l,outgoing:h,buddies:_,received:N,sentGroups:g,myPlans:f}},[t,m,a,n]);return t?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"relative overflow-hidden aspect-[16/9] md:aspect-[16/7]",children:[e.jsx("img",{src:"https://base44.app/api/apps/69d130f86077ee1e918d379c/files/mp/public/69d130f86077ee1e918d379c/e18c17a6a_buddy_hero_100x575.jpg",alt:"Golf buddies",className:"absolute inset-0 w-full h-full object-cover",style:{objectPosition:"center 30%"},fetchpriority:"high",decoding:"async"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-foreground
6/70 via-foreground/40 to-foreground/20"}),e.jsxs("div",{className:"absolute top-4 left-4 right-4",children:[e.jsx("h1",{className:"font-heading text-2xl md:text-5xl font-bold text-white",children:"Buddies"}),e.jsx("p",{className:"mt-4 text-white/70 text-sm md:text-lg max-w-lg",children:"Connect with members, then send notes and Group Outing shares to your buddy list."})]})]}),e.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-6 py-10",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground bg-muted/40 border border-border rounded-lg py-2.5 px-4 mb-6",children:"To best use our site features, make sure your profile includes your name (or nickname) and a photo or avatar"}),e.jsxs(we,{value:i,onValueChange:u,children:[e.jsxs(Q,{className:"w-full justify-start flex-wrap",children:[e.jsxs(q,{value:"buddies",children:[e.jsx(Ge,{className:"w-4 h-4 mr-1"})," Buddies"]}),e.jsxs(q,{value:"requests",children:["Requests",x.incoming.length>0&&e.jsx("span",{className:"ml-1 bg-primary text-primary-foreground text-xs rounded-full px-1.5",children:x.incoming.length})]}),e.jsxs(q,{value:"messages",children:[e.jsx(Me,{className:"w-4 h-4 mr-1"})," Messages",x.received.length>0&&e.jsx("span",{className:"ml-1 bg-primary text-primary-foreground text-xs rounded-full px-1.5",children:x.received.length})]})]}),e.jsxs(E,{value:"buddies",className:"mt-6 space-y-6",children:[e.jsx(rt,{me:t,requests:m,onDone:b}),e.jsx(ot,{buddies:x.buddies,myPlans:x.myPlans,me:t,onSent:b})]}),e.jsx(E,{value:"requests",className:"mt-6",children:e.jsx(nt,{incoming:x.incoming,outgoing:x.outgoing,onAction:b})}),e.jsx(E,{value:"messages",className:"mt-6",children:e.jsx(it,{received:x.received,sentGroups:x.sentGroups})})]})]})]}):e.jsxs("div",{className:"max-w-xl mx-auto px-4 py-20 text-center",children:[e.jsx("h1",{className:"font-heading text-2xl font-bold mb-2",children:"Please log in"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"You need an account to connect with buddies."}),e.jsx(F,{onClick:o,children:"Log in"})]})}export{ht as default};

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.