PageSourceSearch

https://toptiermedia.tv/assets/eventInviteAccept-DpVjHXgj.js

js toptiermedia.tv collected 2026-10-05 08:56:23 UTC 11,236 bytes, 1 lines download raw bytes

1import{a as A,u as U,r as _,b,s as o,d as D,F as N,j as e,X as Q,B as R,C as T,l as B,J as L,E as W,M as G}from"./index-DH6psoju.js";import{C as z,A as J}from"./AddressPopover-BjedJrCX.js";import{A as M,a as F,b as P}from"./avatar-CaaJ6bRI.js";import{E as O}from"./EventRsvpSection-DFr4lKJp.js";import{c as X}from"./useFriends-C2stRM-P.js";import{I as H}from"./input-DZxI0E4a.js";import{S as $}from"./send-B2bGwPuW.js";import{M as V}from"./mentions-BvxWZiR3.js";import{P as Y}from"./pin-BSlZbceF.js";import{a as Z,C as ee}from"./chevron-up-CY7ChD2D.js";import{U as te}from"./users-BXNWnRQS.js";import{f as se}from"./formatDistanceToNow-BA5Xbb0h.js";function re({eventId:t,onClose:x}){const{user:a}=A(),h=U(),{data:d=[]}=X(),[c,p]=_.useState(""),{data:v=[]}=b({queryKey:["event-invites-sent",t,a==null?void 0:a.id],queryFn:async()=>{if(!a)return[];const{data:s,error:i}=await o.from("event_invites").select("id, invitee_id").eq("event_id",t).eq("inviter_id",a.id);if(i)throw i;return s||[]},enabled:!!a}),{data:f=[]}=b({queryKey:["event-rsvps",t],queryFn:async()=>{const{data:s,error:i}=await o.rpc("get_event_attendees",{p_event_id:t});if(i)throw i;return s||[]}}),k=_.useMemo(()=>new Map(v.map(s=>[s.invitee_id,s.id])),[v]),C=_.useMemo(()=>new Set(f.map(s=>s.user_id)),[f]),q=_.useMemo(()=>{const s=c.trim().toLowerCase();return d.filter(i=>i!=null&&i.id?s?(i.display_name||"").toLowerCase().includes(s):!0:!1)},[d,c]),E=D({mutationFn:async s=>{if(!a)throw new Error("Not authenticated");const{data:i,error:l}=await o.from("event_invites").insert({event_id:t,inviter_id:a.id,invitee_id:s}).select("id").single();if(l)throw l;const{data:m}=await o.from("announcements").select("title").eq("id",t).maybeSingle(),{error:w}=await o.from("messages").insert({sender_id:a.id,receiver_id:s,content:`📅 Event Invite${m!=null&&m.title?`: ${m.title}`:""}`,message_type:"event_invite",event_invite_id:(i==null?void 0:i.id)??null});w&&console.error("[EventInviteSearch] invite DM failed",w)},onSuccess:()=>{h.invalidateQueries({queryKey:["event-invites-sent",t]}),N.success("Invite sent"),p("")},onError:s=>{(s==null?void 0:s.code)==="23505"||((s==null?void 0:s.message)||"").includes("event_invites_unique")?N.error("Already invited"):N.error((s==null?void 0:s.message)||"Failed to send invite")}}),y=D({mutationFn:async s=>{await o.from("messages").delete().eq("event_invite_id",s);const{error:i}=await o.from("event_invites").delete().eq("id",s);if(i)throw i},onSuccess:()=>{h.invalidateQueries({queryKey:["event-invites-sent",t]}),h.invalidateQueries({queryKey:["event-invites-incoming"]}),N.success("Invite removed")},onError:s=>N.error((s==null?void 0:s.message)||"Failed to remove invite")}),n=s=>s.stopPropagation();return e.jsxs("div",{className:"mt-2 rounded-lg border border-border bg-muted/30 p-2 space-y-2",onTouchStart:n,onTouchMove:n,onTouchEnd:n,onPointerDown:n,onPointerMove:n,onWheel:n,"data-hscroll-lock":"true",children:[e.jsxs("div",{className:"flex items-center gap-2",onTouchStart:n,onTouchMove:n,children:[e.jsx(H,{autoFocus:!0,value:c,onChange:s=>p(s.target.value),placeholder:"Search connections to invite…",className:"h-8 text-xs"}),e.jsx("button",{onClick:x,className:"p-1 rounded-md hover:bg-muted text-muted-foreground","aria-label":"Close invite search",children:e.jsx(Q,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",style:{touchAction:"pan-y",overscrollBehavior:"contain",WebkitOverflowScrolling:"touch"},onTouchStart:n,onTouchMove:n,onWheel:n,children:q.length===0?e.jsx("p",{className:"text-[11px] text-muted-foreground text-center py-4",children:d.length===0?"No connections yet":"No matches"}):q.map(s=>{var S,g;const i=k.get(s.id),l=!!i,m=C.has(s.id),w=m||E.isPending||y.isPending;return e.jsxs("div",{className:"flex items-center gap-2 p-1.5 rounded-md hover:bg-card",children:[e.jsxs(M,{className:"h-7 w-7",children:[s.avatar_url?e.jsx(F,{src:s.avatar_url}):null,e.jsx(P,{className:"text-[10px]",children:((g=(S=s.display_name)==null?void 0:S[0])==null?void 0:g.toUpperCase())||"?"})]}),e.jsx("span",{className:"text-xs text-foreground flex-1 truncate",children:s.display_name}),e.jsx(R,{size:"sm",variant:l||m?"outline":"default",className:"h-6 px-2 text-[10px] gap-1",disabled:w,onClick:()=>l?y.mutate(i):E.mutate(s.id),children:m?e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"h-3 w-3"})," Going"]}):l?e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"h-3 w-3"})," Invited"]}):e.jsxs(e.Fragment,{children:[e.jsx($,{className:"h-3 w-3"})," Invite"]})})]},s.id)})})]})}function fe({event:t,enableInvite:x,inviteActions:a}){const h=t.event_date?new Date(t.event_date+"T23:59:59").getTime()<Date.now():!1,d=B(),{user:c}=A(),[p,v]=_.useState(!1),[f,k]=_.useState(!1),[C,q]=_.useState(!1),{data:E}=b({queryKey:["my-event-rsvp",t.id,c==null?void 0:c.id],queryFn:async()=>
1{if(!c)return null;const{data:r}=await o.from("event_rsvps").select("id").eq("event_id",t.id).eq("user_id",c.id).maybeSingle();return r},enabled:!!c&&!!x}),y=!!x&&!!E,{data:n=[]}=b({queryKey:["event-rsvps",t.id],queryFn:async()=>{const{data:r,error:u}=await o.rpc("get_event_attendees",{p_event_id:t.id});if(u)throw u;return r||[]},enabled:y}),s=n.filter(r=>(r.status??"going")==="going"),i=n.filter(r=>r.status==="interested"),l=n.map(r=>r.user_id),{data:m=[]}=b({queryKey:["event-attendee-profiles",t.id,l.join(",")],queryFn:async()=>{if(l.length===0)return[];const{data:r,error:u}=await o.from("profiles").select("id, display_name, avatar_url").in("id",l).neq("status","deleted");if(u)throw u;return r},enabled:y&&l.length>0}),w=new Set(s.map(r=>r.user_id)),S=new Set(i.map(r=>r.user_id)),g=m.filter(r=>w.has(r.id)),I=m.filter(r=>S.has(r.id)),K=t.description&&t.description.length>120;return e.jsxs("div",{className:"rounded-xl bg-card border border-border shadow-sm overflow-hidden cursor-pointer hover:shadow-md transition-shadow relative",onClick:()=>d(`/event/${t.id}`),children:[e.jsxs("div",{className:"flex items-center justify-between px-4 pt-3 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[t.is_pinned&&e.jsx(Y,{className:"h-3 w-3 text-primary flex-shrink-0"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-primary",children:"Event"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:se(new Date(t.created_at),{addSuffix:!0})})]}),e.jsxs("div",{className:"px-4 pb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground mb-2",children:e.jsx(V,{title:t.title})}),e.jsxs("div",{className:"flex flex-col gap-1.5 mb-2",children:[t.event_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(L,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:W(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")})]}),t.event_time&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(z,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:t.event_time})]}),t.event_location&&(c?e.jsx(J,{address:t.event_location,className:"text-sm gap-2"}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground italic",children:[e.jsx(G,{className:"h-4 w-4 flex-shrink-0"}),"Sign in to see address details"]}))]}),t.description&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:`text-xs text-muted-foreground ${p?"":"line-clamp-2"}`,children:t.description}),K&&e.jsx("button",{onClick:r=>{r.stopPropagation(),v(!p)},className:"mt-1 text-xs text-primary hover:text-primary/80 flex items-center gap-0.5 font-medium",children:p?e.jsxs(e.Fragment,{children:["Show less ",e.jsx(Z,{className:"h-3 w-3"})]}):e.jsxs(e.Fragment,{children:["Show more ",e.jsx(ee,{className:"h-3 w-3"})]})})]}),e.jsxs("div",{onClick:r=>r.stopPropagation(),children:[y?e.jsxs("div",{className:"mt-2 space-y-2",children:[f?e.jsx(re,{eventId:t.id,onClose:()=>k(!1)}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>k(!0),disabled:h,className:"inline-flex items-center gap-1 h-7 px-3 rounded-md bg-primary text-primary-foreground text-xs font-semibold hover:bg-primary/90 transition-colors disabled:bg-muted disabled:text-muted-foreground disabled:pointer-events-none",children:[e.jsx($,{className:"h-3 w-3"}),"Invite"]}),e.jsxs("button",{onClick:()=>q(!C),className:"flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(te,{className:"h-3 w-3"}),s.length,t.max_capacity?`/${t.max_capacity}`:""," going",i.length>0?` · ${i.length} interested`:""]})]}),C&&(g.length>0||I.length>0)&&e.jsxs("div",{className:"pt-1 space-y-2",children:[g.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-1",children:["Going (",g.length,t.max_capacity?`/${t.max_capacity}`:"",")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(r=>{var u,j;return e.jsx("button",{onClick:()=>d(`/profile/${r.id}`),className:"rounded-full hover:ring-2 hover:ring-primary/50 transition-all",title:r.display_name,children:e.jsxs(M,{className:"h-8 w-8",children:[r.avatar_url?e.jsx(F,{src:r.avatar_url}):null,e.jsx(P,{className:"text-xs",children:(j=(u=r.display_name)==null?void 0:u[0])==null?void 0:j.toUpperCase()})]})},r.id)})})]}),I.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-1",children:["Interested (",I.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:I.map(r=>{var u,j;return e.jsx("button",{onClick:()=>d(`/profile/${r.id}`),className:"rounded-full hover:ring-2 hover:ring-primary/50 transition-all",title:r.display_name,children:e.jsxs(M,{className:"h-8 w-8",children:[r.avatar_url?e.jsx(F,{src:r.avatar_url}):null,e.jsx(P,{className:"text-xs",children:(j=(u=r.display_name)==null?void 0:u[0])==null?void 0:j.toUpperCase()})]})},r.id)})})]})]})]}):e.jsx(O,{eventId:t.id,ticketUrl:t.ticket_url,ticketPriceCredits:t.ticket_price_credits||0,ticketPriceType:t.ticket_price_type||"credits",ticketPriceDollars:t.ticket_price_dollars||0,maxCapacity:t.max_capacity??null,isPast:h}),a]})]})]})}function ie(t,x){return x||!t||(t.ticket_price_type??"credits")==="dollars"?0:Number(t.ticket_price_credits)||0}async function ge(t,x,a){if((t.ticket_price_type??"credits")==="dollars"&&!a.bypass&&Number(t.ticket_price_dollars)>0)throw new Error("Dollar-based tickets require payment integration. Coming soon!");const d=ie(t,a.bypass),{data:c}=await o.from("event_rsvps").select("id").eq("event_id",t.id).eq("user_id",a.userId).maybeSingle();if(!c){if(d>0){if((a.credits??0)<d)throw new Error("Insufficient credits");const{error:v}=await o.from("profiles").update({credits:(a.credits??0)-d}).eq("id",a.userId);if(v)throw v;const{error:f}=await o.from("credit_transactions").insert({user_id:a.userId,amount:-d,reason:"Event ticket"});f&&console.error("[acceptEventInvite] transaction log failed",f)}const{error:p}=await o.from("event_rsvps").insert({event_id:t.id,user_id:a.userId,credits_paid:d,status:"going"});if(p&&p.code!=="23505")throw p}
1return await o.from("event_invites").delete().eq("id",x),d}export{fe as E,ge as a,ie as e};

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.