1import{j as e}from"./vendor-query-B-OkVY6w.js";import{r as n}from"./vendor-react-UNf91VA9.js";import{bg as Ge,bi as Ze,bj as Xe,bk as et,bl as tt,bm as st,bn as at,bo as nt,O as rt,t as it,Q as je,bb as ot,a1 as q,I as lt,Y as p,C as ct,r as dt,bQ as mt,bf as L,bA as N,bv as X,y as ft,bD as I,bN as ht,bZ as pt,b_ as ut,b$ as xt}from"./index-CVKOWYxn.js";import{c as $,q as gt,r as jt,a as wt,W as we,C as be,b as ye,H as bt,e as yt}from"./MinervaWorkspace-GZOusLLw.js";import{L as J}from"./checkbox-DLcSgs5X.js";import{D as ve,a as Ne,c as Ce,b as _e,d as Se}from"./dialog-Cp8Fxci4.js";import{S as K,a as U,b as V,c as Q,f as G}from"./select-Dm2l1iXQ.js";import{C as P}from"./ColumnFilter-BHdgWqM_.js";import{C as vt}from"./ClearFilters-BcC0VPt0.js";import{M as Fe,L as Nt}from"./forms-model-Bu9nRvMl.js";import{u as Ct,C as _t,a as St}from"./CandidateProfile-BzGLOYhz.js";import{S as kt}from"./search-_0wO5O5i.js";import{S as Ot}from"./send-COvRB3b4.js";import{L as ke}from"./loader-circle-qu0iMpWN.js";import{U as Oe}from"./undo-2-B-ocGTPN.js";import"./vendor-ui-BtDEnNjh.js";import"./vendor-supabase-BtubEpct.js";import"./events-api-DaFbpdZL.js";import"./event-time-CnGVkrWd.js";import"./AlumniGlobe-RCIlQNj1.js";import"./types-KCKahpl3.js";import"./full_logo_white.svg.asset-CgYquE9T.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"./image-3-2QuiYQ.js";import"./check-i990AOOe.js";import"./chevron-down-DA0HHuBt.js";import"./download-DMtRHjGI.js";import"./ellipsis-FzSKQwBp.js";import"./chevron-up-DWvAqdbK.js";import"./calendar-ygWZ2E67.js";import"./linkedin-CFe6aaQA.js";import"./linkedin-icon-BSbH_zm9.js";import"./sparkles-CVTg02bk.js";function Dt(){const[a,i]=n.useState(!1),[l,w]=n.useState(null),m=n.useRef(null),o=n.useCallback(u=>(w(u),i(!0),new Promise(b=>{m.current=b})),[]),_=n.useCallback(u=>{var b;i(!1),(b=m.current)==null||b.call(m,u),m.current=null},[]),Y=e.jsx(Ge,{open:a,onOpenChange:u=>{u||_(!1)},children:e.jsxs(Ze,{children:[e.jsxs(Xe,{children:[e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(Fe,{className:"h-5 w-5 text-accent shrink-0"}),(l==null?void 0:l.title)??"This will send an automatic email"]}),e.jsx(tt,{asChild:!0,children:e.jsx("div",{className:"space-y-2",children:l==null?void 0:l.description})})]}),e.jsxs(st,{children:[e.jsx(at,{onClick:()=>_(!1),children:(l==null?void 0:l.cancelLabel)??"No"}),e.jsx(nt,{onClick:()=>_(!0),children:(l==null?void 0:l.confirmLabel)??"Yes, proceed"})]})]})});return{confirm:o,dialog:Y}}const At=["analyst","senior_analyst","team_leader","portfolio_manager","media_analyst","operations_analyst"],Te=a=>a.offer_division||I(a),$t=a=>{const i=a.offer_role;return i&&!W(i,Te(a))?i:I(a)===xt?"media_analyst":"analyst"},Lt=["equity","investment","macro","portfolio","quant"];function W(a,i){return i?a==="media_analyst"?i==="media"?null:"Media & Communication Analysts always belong to Media & Communication.":a==="operations_analyst"?i==="operations"?null:"Operations Analysts always belong to Operations.":a==="portfolio_manager"?i==="portfolio"?null:"Portfolio Manager always belongs to Portfolio Management.":a==="team_leader"&&i==="portfolio"?"Portfolio Management's team leader is the Portfolio Manager role.":Lt.includes(i)?null:`${L(a,null)} is a research role. For the joint intake, choose "Media & Communication Analyst" or "Operations Analyst".`:"Choose the division this role belongs to."}const De=a=>a.offer_division?X[a.offer_division]:ft(I(a)),Ae={ready:"Ready to offer",sent:"Offer sent, awaiting reply",declined:"Declined / expired",joined:"Joined",withdrawn:"Offer withdrawn"};function C(a){return a.status==="joined"?{key:"joined",label:"Joined",tone:"bg-emerald-50 text-emerald-700 border-emerald-200",canOffer:!1,resend:!1,canWithdraw:!1}:a.offer_withdrawn_at&&a.status!=="accepted"?{key:"withdrawn",label:`Offer withdrawn · ${new Date(a.offer_withdrawn_at).toLocaleDateString()}`,tone:"bg-red-50 text-red-700 border-red-200",canOffer:!0,resend:!0,canWithdraw:!1}:a.status==="offer_declined"?{key:"declined",label:"Declined / expired",tone:"bg-orange-50 text-orange-700 border-orange-200",canOffer:!0,resend:!0,canWithdraw:!1}:a.status==="accepted"&&a.offer_sent_at?{key:"sent",label:`Offer sent · awaiting reply${a.offer_deadline?` · by ${new Date(a.offer_deadline).toLocaleDateString()}`:""}`,tone:"bg-amber-50 text-amber-700 border-amber-200",canOffer:!0,resend:!0,canWithdraw:!0}
1:{key:"ready",label:"Ready to offer",tone:"bg-muted text-muted-foreground border-separator",canOffer:!0,resend:!1,canWithdraw:!0}}const Z=a=>a.selected_at||a.offer_sent_at||a.created_at,$e=a=>a?new Date(a).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"",Le=a=>a.offer_division||I(a);function xs(){const{session:a}=rt(),{toast:i}=it(),{canManage:l}=je(),w=l("applications-joiners"),{openId:m,detail:o,cvUrl:_,answerUrl:Y,loading:u,docsLoading:b,open:z,close:Me,refresh:ee}=Ct(a),{hasSpecial:Ee}=je(),Re=ot(),te=l("applications-screening")||Ee("applications-screening","candidates_notes_only"),Pe=Re&&te&&!l("applications-screening"),{confirm:se,dialog:We}=Dt(),[F,Ie]=n.useState([]),[ae,ne]=n.useState(!0),[d,T]=n.useState(null),[f,re]=n.useState("analyst"),[x,M]=n.useState("equity"),[ie,oe]=n.useState(!0),[le,ce]=n.useState(!1),B=async()=>{ne(!0);try{Ie(await ht(a))}catch(t){i({title:"Failed to load",description:t instanceof Error?t.message:void 0,variant:"destructive"})}finally{ne(!1)}};n.useEffect(()=>{B()},[]);const[E,Ye]=n.useState($().key),g=E!==$().key,ze=n.useMemo(()=>{const t=F.filter(r=>["accepted","joined","offer_declined"].includes(r.status)),s=gt(t.map(r=>r.created_at));return s.some(r=>r.key===$().key)||s.unshift($()),s},[F]),c=n.useMemo(()=>F.filter(t=>["accepted","joined","offer_declined"].includes(t.status)||!!t.offer_withdrawn_at).filter(t=>jt(t.created_at).key===E).sort((t,s)=>Z(t).localeCompare(Z(s))||`${t.surname} ${t.first_name}`.localeCompare(`${s.surname} ${s.first_name}`)),[F,E]),[R,de]=n.useState(""),[S,me]=n.useState([]),[k,fe]=n.useState([]),[O,he]=n.useState([]),[D,pe]=n.useState([]),Be=(S.length?1:0)+(k.length?1:0)+(O.length?1:0)+(D.length?1:0)+(R.trim()?1:0),He=()=>{me([]),fe([]),he([]),pe([]),de("")},h=n.useMemo(()=>{const t=R.trim().toLowerCase();return c.filter(s=>S.length===0||S.includes(Le(s))).filter(s=>k.length===0||k.includes(C(s).key)).filter(s=>O.length===0||O.includes(s.academic_year)).filter(s=>D.length===0||D.includes((s.degree_course??"").trim())).filter(s=>!t||`${s.first_name} ${s.surname} ${s.email} ${s.bocconi_id}`.toLowerCase().includes(t))},[c,R,S,k,O,D]),qe=n.useMemo(()=>{const t=new Map;for(const s of c)t.set(Le(s),De(s));return[...t].sort((s,r)=>s[1].localeCompare(r[1])).map(([s,r])=>({value:s,label:r}))},[c]),Je=n.useMemo(()=>{const t=new Set(c.map(s=>C(s).key));return Object.keys(Ae).filter(s=>t.has(s)).map(s=>({value:s,label:Ae[s]}))},[c]),Ke=n.useMemo(()=>{const t=new Set(c.map(s=>s.academic_year));return Object.keys(q).filter(s=>t.has(s)).map(s=>({value:s,label:q[s]}))},[c]),Ue=n.useMemo(()=>{const t=new Set;for(const s of c){const r=(s.degree_course??"").trim();r&&t.add(r)}return[...t].sort((s,r)=>s.localeCompare(r)).map(s=>({value:s,label:s}))},[c]),j=n.useMemo(()=>m?h.findIndex(t=>t.id===m):-1,[h,m]),y=j>0?h[j-1]:null,v=j>=0&&j<h.length-1?h[j+1]:null,ue=n.useRef(null);n.useEffect(()=>{var t;(t=ue.current)==null||t.scrollTo({top:0})},[m]);const[H,xe]=n.useState(null),ge=async t=>{const s=!!t.offer_sent_at;if(await se({title:"Withdraw this offer?",description:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["The offer to ",e.jsxs("strong",{children:[t.first_name," ",t.surname]})," will be withdrawn and their candidacy closed."," ",s?e.jsxs(e.Fragment,{children:["They will receive the ",e.jsx("strong",{children:"Offer withdrawn"})," email, and can no longer accept the offer from their workspace."]}):e.jsxs(e.Fragment,{children:["The offer was never sent, so they will receive the usual ",e.jsx("strong",{children:"post-interview rejection"})," email and will not learn of the offer."]})]}),e.jsx("p",{children:"This cannot be undone, except by sending them a new offer."})]}),confirmLabel:"Yes, withdraw the offer"})){xe(t.id);try{await pt(a,t.id),i({title:"Offer withdrawn",description:`${t.first_name} ${t.surname} has been emailed${s?" that the offer is withdrawn":" the rejection"}.`}),await B(),m===t.id&&await ee(t.id)}catch(A){i({title:"Could not withdraw the offer",description:A instanceof Error?A.message:void 0,variant:"destructive"})}finally{xe(null)}}},Ve=t=>{T(t);const s=$t(t);re(s);const r=N(s),A=Te(t);M(r.length===0||r.includes(A)?A:r[0]),oe(t.offer_fee_due!==!1)},Qe=async()=>
1{if(!(!d||!await se({title:"Send this offer by email?",description:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[d.first_name," ",d.surname]})," will receive an automatic email inviting them to join as"," ",e.jsx("strong",{children:L(f,x)}),". They have three days to accept from their workspace (a reminder email is sent after two days)."]}),e.jsx("p",{children:"This action cannot be reversed. Have you checked the role and division are correct?"})]}),confirmLabel:"Yes, send the offer"}))){ce(!0);try{await ut(a,d.id,f,x,ie),i({title:"Offer sent",description:`${d.first_name} ${d.surname} has 3 days to accept. They will receive an email.`}),T(null),await B()}catch(s){i({title:"Could not send the offer",description:s instanceof Error?s.message:void 0,variant:"destructive"})}finally{ce(!1)}}};return e.jsxs("div",{children:[e.jsx(wt,{title:"Offers",description:"Offers to the candidates who passed selection."}),!w&&e.jsxs("div",{className:"flex items-start gap-2 mb-6 rounded-lg border border-separator bg-muted/30 px-4 py-3 font-body text-sm",children:[e.jsx(Nt,{className:"h-4 w-4 mt-0.5 text-accent shrink-0"}),e.jsxs("span",{className:"text-muted-foreground",children:["This page is ",e.jsx("span",{className:"text-foreground",children:"view-only"})," for your role. You can see the offer process to understand how it works, but sending, resending and editing offers is reserved for the President and Admin."]})]}),e.jsxs("div",{className:"mb-4 flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(kt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(lt,{className:"pl-10 font-body",placeholder:"Search by name, email or Bocconi ID",value:R,onChange:t=>de(t.target.value)})]}),e.jsx(vt,{count:Be,onClear:He,size:"sm"}),e.jsxs(K,{value:E,onValueChange:Ye,children:[e.jsx(U,{className:"w-[220px] font-body",children:e.jsx(V,{})}),e.jsx(Q,{children:ze.map(t=>e.jsxs(G,{value:t.key,children:[t.label,t.key===$().key?" (current)":" (archive)"]},t.key))})]}),g&&e.jsx("span",{className:"font-body text-sm text-muted-foreground",children:"Archived semester: a read-only record of past offers."})]}),ae?e.jsx(we,{}):c.length===0?e.jsx(be,{children:e.jsx(ye,{className:"py-12 text-center",children:e.jsx("p",{className:"font-body text-muted-foreground",children:g?"No offers were recorded in this semester.":"No candidates ready for an offer."})})}):h.length===0?e.jsx(be,{children:e.jsx(ye,{className:"py-12 text-center",children:e.jsx("p",{className:"font-body text-muted-foreground",children:"No offers match the current filters."})})}):e.jsx("div",{className:"max-w-full border border-separator overflow-x-auto",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",title:"When the candidate was selected for an offer. The list is in this order, first selected first.",children:"Selected"}),e.jsx("th",{className:"px-3 py-2 font-normal",children:"Name"}),e.jsx("th",{className:"px-3 py-2 font-normal",children:e.jsx(P,{label:"Division",options:qe,selected:S,onChange:me})}),e.jsx("th",{className:"px-3 py-2 font-normal",children:e.jsx(P,{label:"Year",options:Ke,selected:O,onChange:he})}),e.jsx("th",{className:"px-3 py-2 font-normal",children:e.jsx(P,{label:"Programme",options:Ue,selected:D,onChange:pe})}),e.jsx("th",{className:"px-3 py-2 font-normal",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(P,{label:"Offer",options:Je,selected:k,onChange:fe}),e.jsx(bt,{page:"applications-joiners",topic:"offer-flow"})]})}),e.jsx("th",{className:"px-3 py-2 font-normal text-right",children:"Action"})]})}),e.jsx("tbody",{children:h.map(t=>{const s=C(t);return e.jsxs("tr",{className:"border-t border-separator",children:[e.jsx("td",{className:"px-3 py-2 whitespace-nowrap text-muted-foreground tabular-nums",children:$e(Z(t))}),e.jsxs("td",{className:"px-3 py-2 text-foreground whitespace-nowrap",children:[t.first_name," ",t.surname,e.jsx("div",{className:"text-xs text-muted-foreground",children:t.email})]}),e.jsx("td",{className:"px-3 py-2",children:De(t)}),e.jsx("td",{className:"px-3 py-2 whitespace-nowrap",children:q[t.academic_year]??t.academic_year}),e.jsx("td",{className:"px-3 py-2",children:t.degree_course}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`inline-block px-2 py-0.5 text-xs border ${s.tone}`,children:s.label})}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsxs("div",{className:"inline-flex items-center gap-2",children:[e.jsx(p,{"data-ro":!0,variant:"outline",size:"sm",onClick:()=>z(t.id),children:"Open"}),s.canOffer&&w&&!g&&e.jsxs(p,{size:"sm",onClick:()=>Ve(t),children:[e.jsx(Ot,{className:"h-4 w-4 mr-2"}),s.resend?"Resend offer":"Send offer"]}),s.canWithdraw&&w&&!g&&e.jsx(p,{size:"sm",variant:"outline",className:"text-destructive border-destructive/40 hover:bg-destructive/5 hover:text-destructive",disabled:H===t.id,onClick:()=>ge(t),title:"Withdraw this offer and close the candidacy. The candidate is emailed.",children:H===t.id?e.jsx(ke,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:"h-4 w-4 mr-2"}),"Withdraw"]})})]})})]},t.id)})})]})}),!ae&&c.length>0&&e.jsxs("p",{className:"font-body text-xs text-muted-foreground mt-3",children:["Showing ",h.length," of ",c.length," offer",c.length!==1?"s":"",", in the order the candidates were selected."]}),e.jsx(ve,{open:!!m,onOpenChange:t=>{t||Me()},children:e.jsxs(Ne,{ref:ue,className:"max-w-[96vw] w-[96vw] max-h-[94vh] overflow-y-auto",children:[e.jsxs(Ce,{children:[e.jsxs("div",{className:"flex items-center gap-3 pr-10",children:[e.jsx(_e,{className:"font-serif text-2xl min-w-0 truncate",children:o?`${o.application.first_name} ${o.application.surname}`:"Candidate"}),h.length>1&&e.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-1",children:[e.jsx(p,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8",disabled:!y,onClick:()=>y&&z(y.id),title:y?`Previous candidate: ${y.first_name} ${y.surname}`:"This is the first candidate","aria-label":"Previous candidate",children:e.jsx(ct,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-body text-xs text-muted-foreground tabular-nums px-1 whitespace-nowrap",children:j>=0?`${j+1} of ${h.length}`:`${h.length} shown`}),e.jsx(p,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8",disabled:!v,onClick:()=>v&&z(v.id),title:v?`Next candidate: ${v.first_name} ${v.surname}`:"This is the last candidate","aria-label":"Next candidate",children:e.jsx(dt,{className:"h-4 w-4"})})]})]}),e.jsx(Se,{className:"font-body",children:"The same information the reviewers s
1aw during screening, including their notes. Progression is not changed from here."})]}),u||!o?e.jsx(we,{inline:!0}):e.jsxs(_t,{session:a,detail:o,cvUrl:_,answerUrl:Y,docsLoading:b,canAddNotes:te&&!g,notesAllowedInReadOnly:Pe&&!g,addNote:async t=>{await mt(a,o.application.id,t)},onNoteAdded:async()=>{await ee(o.application.id)},onError:t=>i({title:"Something went wrong",description:t,variant:"destructive"}),children:[e.jsx(St,{status:o.application.status}),e.jsxs("div",{className:"border border-separator p-3 space-y-1",children:[e.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:"Offer"}),e.jsx("span",{className:`inline-block px-2 py-0.5 text-xs border ${C(o.application).tone}`,children:C(o.application).label}),o.application.offer_role&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Offered as ",L(o.application.offer_role,o.application.offer_division||null),"."]}),o.application.selected_at&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Selected for an offer on ",$e(o.application.selected_at),"."]}),C(o.application).canWithdraw&&w&&!g&&e.jsxs(p,{size:"sm",variant:"outline",className:"mt-2 text-destructive border-destructive/40 hover:bg-destructive/5 hover:text-destructive",disabled:H===o.application.id,onClick:()=>ge(o.application),children:[e.jsx(Oe,{className:"h-4 w-4 mr-2"}),"Withdraw offer"]})]})]})]})}),e.jsx(ve,{open:!!d,onOpenChange:t=>!t&&T(null),children:e.jsxs(Ne,{className:"max-w-md",children:[e.jsxs(Ce,{children:[e.jsxs(_e,{className:"font-serif",children:["Send an offer to ",d==null?void 0:d.first_name," ",d==null?void 0:d.surname]}),e.jsx(Se,{className:"font-body",children:"Choose the role and division for the offer. The candidate has three days to accept from their workspace; on acceptance their account becomes a member with this role. An email is sent now."})]}),e.jsxs("div",{className:"space-y-4 font-body",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(J,{children:"Role"}),e.jsxs(K,{value:f,onValueChange:t=>{const s=t;re(s);const r=N(s);r.length===1?M(r[0]):r.includes(x)||M(r[0]??"equity")},children:[e.jsx(U,{children:e.jsx(V,{})}),e.jsx(Q,{children:At.map(t=>e.jsx(G,{value:t,children:L(t,null)},t))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(J,{children:"Division"}),e.jsxs(K,{value:x,onValueChange:t=>M(t),disabled:N(f).length===1,children:[e.jsx(U,{children:e.jsx(V,{placeholder:"Choose a division"})}),e.jsx(Q,{children:N(f).map(t=>e.jsx(G,{value:t,children:X[t]},t))})]}),N(f).length===1&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[L(f,null)," always belongs to ",X[N(f)[0]],"."]}),W(f,x)&&e.jsx("p",{className:"text-xs text-destructive",role:"alert",children:W(f,x)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(J,{htmlFor:"feeDue",children:"Membership fee due"}),e.jsx(yt,{id:"feeDue",checked:ie,onCheckedChange:oe})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only Bocconi students can become members, and payment of the membership fee is a condition of membership."}),e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-800",children:[e.jsx(Fe,{className:"h-4 w-4 mt-0.5 shrink-0"}),e.jsx("span",{children:"Sending an offer emails the candidate automatically. You will be asked to confirm."})]}),e.jsxs("div",{className:"flex gap-3 pt-1",children:[e.jsx(p,{className:"flex-1",onClick:Qe,disabled:le||!!W(f,x),children:le?e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending"]}):"Send offer"}),e.jsx(p,{variant:"outline",onClick:()=>T(null),children:"Cancel"})]})]})]})}),We]})}export{xs 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.