1import{u as K,a as y,d as b,j as e}from"./vendor-query-D4EqUurW.js";import{P as Q}from"./PublicImage-C2h17G23.js";import{d as z,u as R,h as v,B as n,r as J,j as U,k as W,l as $,x as _,a1 as G,a$ as Z,a4 as X,y as Y,z as ee,D as se,N as te,ao as ae,ap as ie,ar as ne,as as le,at as re,au as de,av as ce,aw as oe,ay as me,J as V,aO as ue,aP as xe,s as ve}from"./index-Cu8EkTtj.js";import{m as he,u as pe,a as h,L as p}from"./vendor-react-C3GqM1gX.js";import{p as je}from"./purify.es-jLCuLCx5.js";import{c as fe}from"./linkify-DV_ZGw3S.js";import{d as ge,a as we,b as Ne,e as ye}from"./eventService-DqSRaN15.js";import{p as D,V as j}from"./parseISO-B8WZH4aW.js";import{f}from"./format-B1zFq_Gt.js";import"./vendor-radix-lN3M3gwn.js";/** 2 * @license lucide-react v0.462.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 be=z("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]),g=({children:i})=>e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsx(ue,{}),e.jsx("main",{className:"flex-grow container max-w-4xl mx-auto py-10 px-4 sm:px-6",children:i}),e.jsx(xe,{})]});function Ae(){const{id:i}=he(),C=pe(),m=K(),[E,T]=h.useState(!1),[k,w]=h.useState(!1),[S,c]=h.useState(!1),{t}=R(),{data:s,isLoading:F}=y({queryKey:["event",i],queryFn:()=>ye(i),enabled:!!i}),{data:l}=y({queryKey:["session"],queryFn:async()=>{const{data:a}=await ve.auth.getSession();return a.session}}),o=b({mutationFn:({eventId:a,status:d})=>we(a,d),onSuccess:()=>{m.invalidateQueries({queryKey:["event",i]})}}),r=b({mutationFn:a=>Ne(a),onSuccess:a=>{if(!a){c(!0);return}w(!1),m.removeQueries({queryKey:["event",i],exact:!0}),m.invalidateQueries({queryKey:["events"]}),C("/events")},onError:()=>c(!0)}),u=a=>{if(!l){V.error(t("eventView.mustBeLoggedIn"));return}o.mutate({eventId:i,status:a})},P=()=>{i&&!r.isPending&&(c(!1),r.mutate(i))},A=async()=>{const a=window.location.href;if(navigator.share)try{await navigator.share({title:s?.title,text:s?.description||void 0,url:a})}catch(d){console.error("Error sharing:",d),N(a)}else N(a)},N=a=>{navigator.clipboard.writeText(a).then(()=>V.success(t("eventView.linkCopied"))).catch(d=>console.error("Failed to copy:",d))};if(F)return e.jsxs(g,{children:[e.jsx(v,{title:t("eventView.loading")}),e.jsx("div",{className:"text-center",children:t("eventView.loading")})]});if(!s)return e.jsxs(g,{children:[e.jsx(v,{title:t("eventView.notFound")}),e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl font-bold mb-4",children:t("eventView.notFound")}),e.jsx("p",{className:"text-muted-foreground mb-6",children:t("eventView.notFoundDescription")}),e.jsx(n,{asChild:!0,children:e.jsx(p,{to:"/events",children:t("eventView.backToEvents")})})]})]});const x=D(s.start_date),L=s.end_date?D(s.end_date):x,M=l?.user?.id===s.user_id,O=new Date(s.end_date||s.start_date)<new Date,q=f(x,"EEEE d MMMM yyyy",{locale:J()}),I=f(x,"HH:mm"),H=f(L,"HH:mm"),B=Intl.DateTimeFormat().resolvedOptions().timeZone;return e.jsxs(g,{children:[e.jsx(v,{title:s.title,description:s.description?.slice(0,160)||t("eventView.seoDescription")}),e.jsxs("div",{className:"flex flex-col space-y-8",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(p,{to:"/events",className:"text-sm text-muted-foreground hover:underline",children:t("eventView.breadcrumbEvents")}),e.jsx("span",{className:"text-muted-foreground",children:"/"}),e.jsx("span",{className:"text-sm",children:t("eventView.eventDetails")})]}),e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:s.title})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.is_online&&e.jsxs(U,{variant:"outline",className:"flex items-center gap-1",children:[e.jsx(j,{className:"h-3 w-3"}),e.jsx("span",{children:t("eventView.virtual")})]})})]}),s.cover_image_url&&e.jsx("div",{className:"w-full aspect-video rounded-lg overflow-hidden",children:e.jsx(Q,{src:s.cover_image_url,alt:s.title,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:t("eventView.aboutEvent")}),e.jsx("div",{className:"whitespace-pre-wrap prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:je.sanitize(fe(s.description||""),{ALLOWED_TAGS:["a","br"],ALLOWED_ATTR:["href","target","rel","class"]})}})]}),s.is_online&&s.meeting_url&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:t("eventView.meetingLink")}),E?e.jsx("div",{className:"aspect-video w-full mb-4",children:s.meeting_url.includes("youtube")||s.meeting_url.includes("youtu.be")?e.jsx("iframe",{className:"w-full h-full rounded-lg",src:s.meeting_url.includes("embed")?s.meeting_url:s.meeting_url.replace("watch?v=","embed/"),title:s.title,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):s.meeting_url.includes("jitsi")||s.meeting_url.includes("meet.")?e.jsx("iframe",{className:"w-full h-full rounded-lg",src:s.meeting_url,title:s.title,frameBorder:"0",allow:"camera; microphone; fullscreen; display-capture",allowFullScreen:!0}):e.jsx("div",{className:"h-full w-full flex items-center justify-center bg-muted rounded-lg",children:e.jsxs("div",{className:"text-center p-6",children:[e.jsx(j,{className:"mx-auto h-12 w-12 text-muted-foreground mb-2"}),e.jsx("h3",{className:"text-lg font-medium mb-1",children:t("eventView.meetingLink")}),e.jsx("a",{href:s.meeting_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline break-all",children:s.meeting_url})]})})}):e.jsxs(n,{variant:"outline",className:"w-full h-40 flex flex-col items-center justify-center gap-3",onClick:()=>T(!0),children:[e.jsx(j,{className:"h-10 w-10"}),e.jsx("span",{children:t("eventView.clickToViewMeeting")})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(W,{children:e.jsxs($,{className:"pt-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{className:"h-5 w-5 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t("eventView.dateAndTime")}
6),e.jsx("div",{className:"text-sm text-muted-foreground",children:q}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[I," - ",H," (",B,")"]})]})]}),s.location&&!s.is_online&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(G,{className:"h-5 w-5 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t("eventView.location")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s.location})]})]}),s.max_attendees&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Z,{className:"h-5 w-5 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t("eventView.capacity")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s.rsvp_count||0," / ",s.max_attendees," ",t("eventView.attendees")]})]})]})]}),e.jsx(X,{className:"my-6"}),!O&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(n,{className:"w-full",variant:s.user_rsvp_status==="attending"?"default":"outline",disabled:!l||o.isPending,onClick:()=>u("attending"),children:s.user_rsvp_status==="attending"?t("eventView.attending"):t("eventView.attendEvent")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(n,{variant:s.user_rsvp_status==="maybe"?"default":"outline",className:"flex-1",disabled:!l||o.isPending,onClick:()=>u("maybe"),children:s.user_rsvp_status==="maybe"?t("eventView.maybeConfirmed"):t("eventView.maybe")}),e.jsx(n,{variant:s.user_rsvp_status==="declined"?"destructive":"outline",className:"flex-1",disabled:!l||o.isPending,onClick:()=>u("declined"),children:s.user_rsvp_status==="declined"?t("eventView.declined"):t("eventView.decline")})]})]})]})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(n,{variant:"outline",onClick:()=>ge(s),className:"gap-2",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("eventView.addToCalendar")})]}),e.jsx(Y,{children:e.jsxs(ee,{children:[e.jsx(se,{asChild:!0,children:e.jsx(n,{variant:"outline",size:"icon",onClick:A,"aria-label":t("eventView.shareEvent"),children:e.jsx(be,{className:"h-4 w-4"})})}),e.jsx(te,{children:e.jsx("p",{children:t("eventView.shareEvent")})})]})})]}),M&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(n,{asChild:!0,variant:"outline",children:e.jsx(p,{to:`/events/edit/${s.id}`,children:t("eventView.editEvent")})}),e.jsxs(ae,{open:k,onOpenChange:a=>{r.isPending||(w(a),c(!1))},children:[e.jsx(ie,{asChild:!0,children:e.jsx(n,{variant:"destructive",children:t("eventView.deleteEvent")})}),e.jsxs(ne,{children:[e.jsxs(le,{children:[e.jsx(re,{children:t("eventView.deleteConfirmTitle")}),e.jsx(de,{children:t("eventView.deleteConfirmDescription")})]}),S&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:t("toasts.eventDeleteFailed")}),e.jsxs(ce,{children:[e.jsx(oe,{disabled:r.isPending,children:t("common.cancel")}),e.jsx(me,{disabled:r.isPending,onClick:a=>{a.preventDefault(),P()},children:t("common.delete")})]})]})]})]})]})]})]})]})}export{Ae 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.