1import{j as e}from"./vendor-query-B-OkVY6w.js";import{r as d}from"./vendor-react-UNf91VA9.js";import{O as M,t as q,I as W,Y as b,bv as F}from"./index-CVKOWYxn.js";import{a as U,W as V,C as k,b as $,q as Y,r as Z,H as G,e as J}from"./MinervaWorkspace-GZOusLLw.js";import{b as K,c as Q,A as u,e as X,f as ee,g as te,h as se,j as O,k as E,m as ae}from"./alumni-aod-api-D_7o-XkS.js";import{a as T,z as A}from"./event-time-CnGVkrWd.js";import{P as ie}from"./dialog-Cp8Fxci4.js";import{T as re}from"./full_logo_white.svg.asset-CgYquE9T.js";import{L as ne}from"./loader-circle-qu0iMpWN.js";import"./vendor-ui-BtDEnNjh.js";import"./vendor-supabase-BtubEpct.js";import"./checkbox-DLcSgs5X.js";import"./check-i990AOOe.js";import"./forms-model-Bu9nRvMl.js";import"./calendar-ygWZ2E67.js";import"./image-3-2QuiYQ.js";import"./events-api-DaFbpdZL.js";import"./AlumniGlobe-RCIlQNj1.js";import"./types-KCKahpl3.js";import"./EventPosterPlaceholder-CL5VfHKJ.js";import"./event-place-DxRCNSCg.js";import"./workspace-nav-GS4rx2kf.js";import"./calendar-days-Cx8Wz7Iz.js";import"./users-Dw8EzinI.js";import"./search-_0wO5O5i.js";import"./chevron-down-DA0HHuBt.js";import"./download-DMtRHjGI.js";import"./ellipsis-FzSKQwBp.js";const R=8,N=["equity","investment","macro","portfolio","quant"],I=a=>new Set(a.map(l=>l.division).filter(l=>!!l&&N.includes(l))).size,C=a=>a.length>R||I(a)===N.length;function Le(){const{session:a,user:l}=M(),{toast:m}=q(),[p,g]=d.useState([]),[v,y]=d.useState([]),[f,w]=d.useState(!1),[S,r]=d.useState(!0),[n,x]=d.useState(""),[h,c]=d.useState(null),i=async()=>{r(!0);try{const t=await X(a);g(t.days),y(t.signups),w(t.isSenior)}catch(t){m({title:"Failed to load",description:t instanceof Error?t.message:void 0,variant:"destructive"})}finally{r(!1)}};d.useEffect(()=>{i()},[]);const L=async()=>{if(!n){m({title:"Pick a date",variant:"destructive"});return}try{await ee(a,n),x(""),await i()}catch(t){m({title:"Could not create",description:t instanceof Error?t.message:void 0,variant:"destructive"})}},z=(t,s)=>v.filter(o=>o.day_id===t&&o.slot_time===s),j=new Date().toISOString().slice(0,10),D=d.useMemo(()=>p.filter(t=>t.event_date>=j).sort((t,s)=>t.event_date.localeCompare(s.event_date)),[p,j]),_=d.useMemo(()=>p.filter(t=>t.event_date<j).sort((t,s)=>s.event_date.localeCompare(t.event_date)),[p,j]),P=t=>u.filter(s=>C(v.filter(o=>o.day_id===t&&o.slot_time===s))).length,B=async(t,s)=>{c(`${t}-${s}`);try{await te(a,t,s),await i()}catch(o){m({title:"Could not sign up",description:o instanceof Error?o.message:void 0,variant:"destructive"})}finally{c(null)}},H=async t=>{try{await se(a,t),await i()}catch(s){m({title:"Could not remove",description:s instanceof Error?s.message:void 0,variant:"destructive"})}};return e.jsxs("div",{children:[e.jsx(U,{title:"Association On Display",description:"Stand days, and the slots people have signed up for."}),f&&e.jsxs("div",{className:"flex gap-2 mb-6 font-body",children:[e.jsx(W,{type:"date",value:n,onChange:t=>x(t.target.value),className:"max-w-[200px]"}),e.jsxs(b,{variant:"outline",onClick:L,children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),"Add a day"]})]}),S?e.jsx(V,{}):p.length===0?e.jsx(k,{children:e.jsx($,{className:"py-12 text-center",children:e.jsx("p",{className:"font-body text-muted-foreground",children:"No Association on Display day scheduled yet."})})}):e.jsxs("div",{className:"space-y-8",children:[D.length===0?e.jsx(k,{children:e.jsx($,{className:"py-10 text-center",children:e.jsx("p",{className:"font-body text-muted-foreground",children:"No upcoming Association on Display day."})})}):D.map(t=>e.jsx(oe,{day:t,isSenior:f,userId:(l==null?void 0:l.id)??null,signupsFor:s=>z(t.id,s),busySlot:h,onSignup:s=>B(t.id,s),onRemove:H,onToggleOpen:async s=>{try{await K(a,t.id,s),await i()}catch(o){m({title:"Could not update",description:o instanceof Error?o.message:void 0,variant:"destructive"})}},onDelete:async()=>{if(confirm("Delete this day and all signups?"))try{await Q(a,t.id),await i()}catch(s){m({title:"Could not delete",description:s instanceof Error?s.message:void 0,variant:"destructive"})}}},t.id)),_.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-serif text-lg text-accent mb-2",children:"Past sessions"}),e.jsx("div",{className:"border border-separator",children:e.jsxs("table",{className:"w-full text-left font-body text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 font-normal",children:"Date"}),e.jsx("th",{className:"px-3 py-2 font-normal",children:"Slots covered"})]})}),e.jsx("tbody",{children:Y(_.map(t=>t.event_date)).map(t=>e.jsxs(d.Fragment,{children:[e.jsx("tr",{className:"border-t border-separator bg-accent/5",children:e.jsx("td",{colSpan:2,className:"px-3 py-1.5 font-serif text-accent uppercase tracking-wider text-xs",children:t.label})}),_.filter(s=>Z(s.event_date).key===t.key).map(s=>e.jsxs("tr",{className:"border-t border-separator",children:[e.jsx("td",{className:"px-3 py-2",children:T(`${s.event_date}T12:00:00Z`)}),e.jsxs("td",{className:"px-3 py-2",children:[P(s.id)," / ",u.length]})]},s.id))]},t.key))})]})})]})]})]})}function oe({day:a,isSenior:l,userId:m,signupsFor:p,busySlot:g,onSignup:v,onRemove:y,onToggleOpen:f,onDelete:w}){const S=d.useMemo(()=>u.filter(r=>C(p(r))).length,[p]);return e.jsxs("div",{className:"border border-separator",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-muted/40 font-body",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-serif text-lg text-accent",children:T(`${a.event_date}T12:00:00Z`)}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[S,"/",u.length," slots covered (more than ",R," people, or all ",N.length," core divisions) ",e.jsx(G,{page:"events-on-display",topic:"coverage"})," · ",a.registration_open?"Registration open":"Registration closed"]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["Each slot runs for ",O," minutes, from its start time to the end of the following half hour, on Rome time (",A(a.event_date),"). There is no limit on how many people can take a slot: the more of us on the stand, the better, so please register even where a slot is already covered."]})]}),l&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Open"}),e.jsx(J,{checked:a.registration_open,onCheckedChange:f}),e.jsx(b,{variant:"destructive",size:"icon",onClick:w,children:e.jsx(re,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-px bg-separator",children:u.map(r=>{const n=p(r),x=n.find(i=>i.user_id===m),h=I(n),c=C(n);return e.jsxs("div",{className:`bg-background p-3 font-body border-l-2 ${c?"border-emerald-500":"border-amber-500"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:E(r)}),e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["to ",E(ae(r))," ",A(a.event_date)]})]}),e.jsx("span",{className:`shrink-0 text-[11px] px-1.5 py-0.5 rounded ${c?"bg-emerald-50 text-emerald-700":"bg-amber-50 text-amber-700"}`,children:c?`Covered · ${n.length}`:`${n.length} · ${h}/${N.length} div.`})]}
1),e.jsxs("div",{"aria-hidden":!0,className:"mt-1.5 flex items-center gap-1",title:`${O} minutes`,children:[e.jsx("span",{className:`h-2 w-px ${c?"bg-emerald-500/60":"bg-amber-500/60"}`}),e.jsx("span",{className:`h-px flex-1 ${c?"bg-emerald-500/35":"bg-amber-500/35"}`}),e.jsx("span",{className:`h-2 w-px ${c?"bg-emerald-500/60":"bg-amber-500/60"}`})]}),e.jsx("div",{className:"mt-2",children:x?e.jsx(b,{"data-ro":!0,variant:"outline",size:"sm",className:"w-full text-destructive border-destructive/40 hover:bg-destructive/10",onClick:()=>y(x.id),children:"Cancel my registration"}):e.jsx(b,{"data-ro":!0,variant:"outline",size:"sm",className:"w-full",disabled:!a.registration_open||g===`${a.id}-${r}`,onClick:()=>v(r),children:g===`${a.id}-${r}`?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):a.registration_open?"Register for this slot":"Registration closed"})}),e.jsxs("div",{className:"mt-2 space-y-0.5",children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:[n.length," registered · ",h," division",h===1?"":"s"," covered"]}),c&&a.registration_open&&!x&&e.jsx("div",{className:"text-[11px] text-emerald-700",children:"Covered, and more are still welcome"}),n.length===0?e.jsx("span",{className:"text-xs text-amber-600",children:"No one yet"}):n.map(i=>e.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:[i.member_name,i.division&&i.division!=="none"?` · ${F[i.division]}`:""]},i.id))]})]},r)})})]})}export{Le 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.