1import{r as s,R as a,f as de}from"./vendor-react-nj2ukvvY.js";import{dH as he,T as pe,G as fe,L as v,I as C,aE as R,E as ee,m9 as be,J as te}from"./index-M7kQB6UT.js";import{v as Ee}from"./index-BRcC2pND.js";import"./vendor-apollo-AvuNUkOJ.js";import"./vendor-moment-CqZOA61p.js";import"./vendor-lodash-CuICpPff.js";/* empty css */import"./SessionSurveyForm-6BaINkOt.js";import"./SurveyForm-BdF13LVk.js";import"./index-BjGjyBSM.js";import"./matrixHelper-XRm2DHD4.js";import"./VenueMapLocationPopup-CbGTgeOq.js";import"./HotspotViewer-D1j18TH5.js";import"./LocationDetailsPopover-BeIEdYA6.js";import"./nestedSessions-DQ1ZieX3.js";import"./index-Cta_1hsI.js";import"./index-CKbzl7aQ.js";import"./NewMeetWeb-Qw9-cxOt.js";import"./Table-CKlNNDT-.js";import"./index-B-R6DyUb.js";import"./index-CvE4olKH.js";import"./SessionFormatLabel-DV-GnLgO.js";import"./index-tg1K6pdh.js";import"./keen-slider.min-DBmVTzQB.js";function qe({attendees:W,sessionId:i,eligibilityMap:y,alreadyRegisteredMap:E,selections:m,onConfirm:B,onCancel:$,key:oe,minSessionsPerAttendee:w,maxSessionsPerAttendee:p,eventUrl:H,orderId:O,triggerRef:u,isInsideModal:S}){var Q,U,Z,P;const{t:r}=he(["common"]),f=s.useRef(null),k=s.useContext(pe),[h,x]=s.useState(new Set),[j,D]=s.useState(!1),[ce,F]=s.useState(new Set),[L,_]=s.useState(null),[z,N]=s.useState(null),[ae,ne]=s.useState({}),[le,V]=s.useState(!1),X=s.useRef((()=>{const e=m==null?void 0:m.get(i),o=(e==null?void 0:e.emails)||e;return(o==null?void 0:o.size)>0})());s.useEffect(()=>{!(u!=null&&u.current)||!f.current||(V(!1),requestAnimationFrame(()=>{if(!(u!=null&&u.current)||!(f!=null&&f.current))return;const e=u.current.getBoundingClientRect(),o=f.current.offsetHeight,c=window.innerHeight-e.bottom<o&&e.top>o,l=4,n={position:S?"fixed":"absolute",zIndex:99999,minWidth:"320px"},d=S?0:window.scrollY,b=S?0:window.scrollX;c?(n.top=`${e.top+d-l}px`,n.left=`${e.right+b}
1px`,n.transform="translate(-100%, -100%)"):(n.top=`${e.bottom+d+l}px`,n.left=`${e.right+b}px`,n.transform="translateX(-100%)"),ne(n),V(!0)}))},[u,S]),s.useEffect(()=>{const e=m==null?void 0:m.get(i),o=(e==null?void 0:e.emails)||e;(o==null?void 0:o.size)>0?x(new Set(o)):x(new Set)},[i,m]),s.useEffect(()=>{const e=o=>{setTimeout(()=>{f.current&&!f.current.contains(o.target)&&(u!=null&&u.current)&&!u.current.contains(o.target)&&$()},0)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[$,u]),s.useEffect(()=>{z!==null&&h.size<=z&&(_(null),N(null))},[h.size,z]);const q=s.useCallback(e=>{var t;return!y||!y.ticketTypeEligibility?!0:((t=e==null?void 0:e.ticketTypeIds)!=null&&t.length?e.ticketTypeIds:[e==null?void 0:e.ticketTypeId]).some(c=>{const l=y.ticketTypeEligibility[c];return Array.isArray(l)&&l.includes(i)})},[y,i]),G=s.useCallback(e=>{var o,t,c;return!!((c=(t=(o=E==null?void 0:E.get)==null?void 0:o.call(E,e==null?void 0:e.toLowerCase()))==null?void 0:t.has)!=null&&c.call(t,i))},[E,i]),A=s.useCallback(e=>{let o=0;return m&&m.forEach(t=>{var l;const c=(t==null?void 0:t.emails)||t;(l=c==null?void 0:c.has)!=null&&l.call(c,e)&&(o+=1)}),o},[m]),J=s.useCallback(e=>{var n,d;if(!p)return!1;const o=A(e),t=m==null?void 0:m.get(i);return(((d=(n=(t==null?void 0:t.emails)||t)==null?void 0:n.has)==null?void 0:d.call(n,e))?o-1:o)>=p},[p,A,m,i]),se=e=>{x(o=>{const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t})},T=W.filter(e=>!(!q(e)||G(e.email)||J(e.email)&&!h.has(e.email))),Y=T.length>0&&T.every(e=>h.has(e.email)),re=()=>{x(e=>{const o=new Set(e);return Y?T.forEach(t=>o.delete(t.email)):T.forEach(t=>o.add(t.email)),o})},ie=async()=>{var o;const e=Array.from(h);if(e.length===0){B(i,[]);return}if(H&&O){D(!0),F(new Set),_(null),N(null);try{const t=await Ee(H,i,O,e);if((t==null?void 0:t.success)==="conflict"&&((o=t==null?void 0:t.conflicts)==null?void 0:o.length)>0){const c=new Set(t.conflicts.map(l=>l.toLowerCase()));F(c),x(l=>{const n=new Set(l);return c.forEach(d=>{for(const b of n)b.toLowerCase()===d&&n.delete(b)}),n});return}if((t==null?void 0:t.success)==="capacity_reached"){const c=t.failedCount||0,l=e.length,n=l-c;c>=l?(N(0),_(r("common:This session is fully booked. No seats are available. Please deselect all {{count}} attendees to continue.",{count:l}))):(N(n),_(r("common:This session has {{available}} {{seatWord}} remaining. Please deselect {{failed}} {{attendeeWord}} to continue.",{available:n,seatWord:r(n===1?"common:seat":"common:seats"),failed:c,attendeeWord:r(c===1?"common:attendee":"common:attendees")})));return}}catch{return}finally{D(!1)}}B(i,e)},g=h.size,K=e=>{var o;return a.createElement(v,{variant:"caption3",color:(o=C[k.theme])==null?void 0:o.danger800,header:e,labelClass:"m-l-24 m-t-2 m-b-0"})},me=()=>a.createElement("div",{className:"checkout-attendee-dropdown__list"},W.map(e=>{var M;const o=q(e),t=G(e.email),c=J(e.email),l=!o||t||c&&!h.has(e.email),n=o?t?r("common:This user already registered in this session"):c?r("common:Maximum sessions reached for this attendee."):"":r("common:This session is not available for {{ticketType}} holders.",{ticketType:e.ticketTypeNames}),d=A(e.email),b=ce.has(e.email.toLowerCase()),I=a.createElement("div",{key:e.email,className:`checkout-attendee-dropdown__item ${l?"checkout-attendee-dropdown__item--disabled":""}`},a.createElement("div",{className:"d-flex justify-space-between align-center w-100p"},a.createElement(R,{id:`checkout-session-${i}-attendee-${e.email}`,checked:h.has(e.email),onChange:()=>!l&&se(e.email),disabled:l,message:e.name,variant:"caption2",className:"m-b-0 checkout-attendee-dropdown__checkbox"}),w&&a.createElement(v,{variant:"caption3",color:(M=C[k.theme])==null?void 0:M.neutral500,header:`${d}/${w}`,labelClass:"m-b-0"})),c&&!h.has(e.email)&&K(r("common:Maximum reached ({{count}}/{{max}})",{count:d,max:p})),b&&K(r("common:User already registered in this session")));return l&&n&&(!c||t)?a.createElement(te,{key:e.email,tooltip:n,overlayProps:{placement:"left"}},I):I})),ue=a.createElement("div",{ref:f,className:fe("checkout-attendee-dropdown",{visible:le}),style:ae,key:oe},a.createElement("div",{className:"checkout-attendee-dropdown__header d-flex justify-space-between align-center"},a.createElement(v,{variant:"custom-captions",color:(Q=C[k.theme])==null?void 0:Q.neutral1000,header:"Save a seat for:",labelClass:"m-b-0"}),(w||p)&&a.createElement(v,{variant:"caption3",color:(U=C[k.theme])==null?void 0:U.neutral500,labelClass:"m-b-0 lh-14 d-flex align-center gap-4"},w?a.createElement("span",null,"Min ",w):null,p&&w?a.createElement("span",{className:"dot-divider"}):null,p?a.createElement("span",null,"Max ",p):null)),T.length>0&&a.createElement("div",{className:"checkout-attendee-dropdown__select-all"},a.createElement(R,{id:`checkout-session-${i}-select-all`,checked:Y,onChange:re,message:r("common:Select All"),variant:"caption2",className:"checkout-attendee-dropdown__select-all-checkbox checkout-attendee-dropdown__checkbox m-b-0"})),me(),L&&a.createElement("div",{className:"checkout-attendee-dropdown__capacity-error"},a.createElement(v,{variant:"caption3",color:(Z=C[k.theme])==null?void 0:Z.danger800,header:L,labelClass:"m-b-0"})),a.createElement("div",{className:"checkout-attendee-dropdown__footer"},a.createElement(v,{variant:"caption3 f-w600 lh-14",header:`${g} ${r("common:selected")}`,color:(P=C[k.theme])==null?void 0:P.neutral500,labelClass:"m-b-0"}),a.createElement("div",{className:"display-flex gap-8 align-center"},a.createElement(ee,{id:"checkout-attendee-cancel-btn",variant:"secondary",size:"small",className:"attendee-register-button m-l-0",label:r("common:Cancel"),onClick:$}),a.createElement(be,{condition:g===0&&!X.current,wrapper:e=>a.createElement(te,{tooltip:r("common:Please select at least one attendee to confirm."),overlayProps:{placement:"top"}},e)},a.createElement(ee,{id:"checkout-attendee-confirm-btn",variant:"primary",size:"small",className:"attendee-register-button m-l-0",label:r("common:Confirm"),onClick:ie,loading:j,disabled:j||!!L||g===0&&!X.current})))));return de.createPortal(ue,document.body)}export{qe 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.