1import{d as e,B as J,D as Oe,a0 as Mt,m as Rt,n as Bt,o as Ut,q as Ht,x as We,y as Pe,ab as Gt}from"./ui-vendor-wXL1vB-g.js";import{r as c,u as ve,R as K,i as Re,L as jt,g as zt,f as qt}from"./react-vendor-BktoabIY.js";import{e as X,u as Te}from"./redux-vendor-DyFZt5ds.js";import{bf as Le,ak as ce,P as _t,ac as Q,a1 as fe,S as we,bn as bt,aS as me,aJ as Me,bm as Wt,bj as Yt,o as Kt,ah as Nt,e as ke,a8 as Ye,aj as Ke,O as Ct,aU as Ze,bQ as ge,av as Zt,$ as se,bR as Jt,bS as Je,bT as Qe,bU as yt,bV as Qt,bW as Xt,aa as es,aQ as ts,bo as ss,bh as De,a3 as Xe,by as as,am as ns,bX as kt,bC as is,aL as rs,bY as os,bZ as Ve,aZ as St,aH as Tt,g as cs,aI as ls,b_ as re,b$ as ds,c0 as ms,c1 as us,bL as hs,bM as et,bN as oe,c2 as ps,c3 as xs,c4 as vs,a7 as tt,a9 as st,c5 as fs,bw as Et,bx as wt,bu as gs,c6 as at,c7 as js,c8 as bs,c9 as Ns,aO as nt,ca as Cs,cb as ys,cc as ks,_ as it,V as Ss,cd as Ts,bq as Es,ce as ws,l as Ds}from"./index-DHpc7hhq.js";import{f as As,F as Ps}from"./filter-dropdown.component-1_MHXcrR.js";import{r as Is,a as Os,f as Fs}from"./donationTimeStampListener-DkXpVS6G.js";import{R as Ls}from"./refresh-sql-data.component-Da9JjHzP.js";import{S as rt}from"./simple-page-size-select.component-WB9MRQ33.js";import{S as ot}from"./simple-pagination-component-D8Y6lqMH.js";import{S as Vs}from"./detailed-pencil-icon-B1y3MD9g.js";import{A as $s}from"./admin-page-title.component-BZeG76-W.js";import{S as Be,C as Ms}from"./event-context-section-edit.component-31Le83TO.js";import{C as R,E as ue,a as Rs,b as Bs,c as Ae,S as Us,u as Hs,d as Gs,e as zs,f as qs}from"./eventCreateDraftEditContext-DvqNR9XT.js";import{S as _s,I as Dt}from"./crossIcon-CW26KtZ-.js";import{I as je}from"./image-previewer-and-edit.component-4OjW3XLh.js";import{I as Ws,C as ct}from"./custom-options.component-DylXWhv1.js";import{M as At}from"./media-library-dialog.component-DZaA_6R9.js";import{J as le}from"./firebase-vendor-DpNCE-dN.js";import{T as Ie}from"./textfield-new.atom-xYya_Ihr.js";import{T as Ue}from"./textarea-new.atom-BF8liSzi.js";import{S as Ys}from"./service-project-reusable-dropdown-B614Kp8e.js";import{S as Ks}from"./ArrowLeft-Dm3lSmxb.js";import{S as Zs}from"./search-with-options.component-hEcK4jUr.js";import{A as Js}from"./ai-prompt-fields.component-Br60ixW_.js";import{R as Qs}from"./rich-text-editor.atom-0SDXpsSI.js";import{u as He}from"./useEventDataFromRedux-NRCQk6mF.js";import{S as Xs,D as ea,A as ta,b as sa,c as aa,a as ye,U as na}from"./utm-links.component-eFkf6De_.js";import{D as lt}from"./date-field.atom-CS4QPmws.js";import{E as ia}from"./edit-overlay.atom-BiyvR4NL.js";import{S as ra}from"./location-Cu1WZ9o4.js";import{S as dt}from"./calendar-jeW4USFq.js";import{S as Pt}from"./tick-Dsj5ZIpT.js";import{D as oa}from"./data-table-wrapper.component-D0dQLfev.js";import{b as ca}from"./allUsers.action-Bq4JxlXp.js";import{S as la}from"./exportIcon-IuewquxF.js";import{c as da,A as ma}from"./audit-logs.component-BW9O2GdC.js";import{S as ua}from"./delete-CVS5AHlv.js";import{u as ha}from"./useGuestList-DPBtzj3F.js";import{T as It}from"./textfield.atom-BBXqKSYt.js";import{S as pa}from"./caret-down-oV2nWz1C.js";/* empty css */import{A as xa}from"./add-remove-component.component-DOf44i2J.js";import{S as va}from"./arrow-down-BO4EdC0X.js";import{E as fa}from"./event-target-achieved-bar.component-C7pFiZca.js";import{C as Ot}from"./copy-to-clipboard.component-CsULwWIn.js";/* empty css */import{S as ga}from"./share-T63zuyC_.js";import{C as ja}from"./custom-modal-header.component-CrD1aPQA.js";import{g as ba}from"./getDataFromApplicationObjects-D0HY_znK.js";import{s as Na}from"./activityLogs-mCGBm_4i.js";import{A as Ca}from"./all-outreach.page-CUd8_OYt.js";import{S as ya}from"./event-modal-cross-icon-DJP5kHA1.js";import{i as ka,s as Sa,c as Ta,u as Ea,d as wa,e as Da,t as Aa,g as Pa,h as Ia,j as Oa}from"./events.action-Dmhr9Qhy.js";import{E as Fa,a as La}from"./event-ticket.step-four.component-C_y-bk8N.js";import"./chart-vendor-CfmrB_PR.js";import"./form-vendor-B7oKYy-s.js";/* empty css */import"./emailCMS.action-GVR1B0Sq.js";import"./select-field.component-BU4r96Yg.js";
1import"./custom-checkbox.component-_sq9xPNR.js";import"./email-cms.component-CmwxXC9J.js";import"./index-B6v--DBm.js";import"./useEmailPreview-CgM82RB0.js";import"./useIdToGetEventType-DKJn7EGK.js";import"./emailCmsFunctions-CB3uVNdy.js";import"./index-COrgFzk6.js";import"./breadcrumbs.component-DaspX0Bz.js";/* empty css */import"./replaceWithDynamicContent-Cmtijmdh.js";import"./textarea.atom-G33f_8PA.js";import"./activity-logs-component-B0AP5S__.js";import"./NewsFeedAvatar-J6DuG0tG.js";import"./useResizeObserver-CAnv0LW_.js";import"./Form-DiZNsYLK.js";import"./arrow-back-CEVELpS_.js";import"./admin-action-button.atom-BdM2wLL_.js";import"./icon-button.atom-CDVUvgEk.js";import"./big-edit-B7MLxmLZ.js";import"./media-library-listing.component-DhKs1EZU.js";import"./media-libarary-styled.components-C3xI6xvu.js";import"./alert-confirmation.component-vmuLS6wT.js";import"./alert-icon-CIy-mDLg.js";import"./column-filter-icon-DxTa9zPj.js";import"./trash-icon-BNtpn1e5.js";import"./custom-csv-button.style-DuAxjoiR.js";import"./add-CZWUD2Tf.js";import"./campaign.action-K_0qWca_.js";/* empty css */import"./typeFilterGpt-D2JIvJgH.js";import"./utm-builder.styles.component-DLbye_aQ.js";/* empty css */import"./index-DdYyfB3z.js";/* empty css */import"./xlsx-APjLrsY0.js";import"./admin-user-profile.action-DsJZGmbw.js";import"./analytics-509EAsrE.js";import"./Check-icon-DuKsGvLy.js";import"./test-cases-ids-DtRGy9e4.js";const Va=t=>c.createElement("svg",{width:30,height:30,viewBox:"0 0 30 30",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("circle",{cx:15,cy:15,r:15,fill:"#FAAC32"}),c.createElement("g",{clipPath:"url(#clip0_5976_46262)"},c.createElement("path",{d:"M21.6667 8.33331C22.0871 8.33318 22.4921 8.49199 22.8005 8.77789C23.1088 9.0638 23.2976 9.45568 23.3292 9.87498L23.3333 9.99998V20C23.3335 20.4205 23.1747 20.8255 22.8888 21.1338C22.6028 21.4421 22.211 21.6309 21.7917 21.6625L21.6667 21.6666H8.33333C7.91285 21.6668 7.50786 21.508 7.19954 21.2221C6.89123 20.9362 6.70237 20.5443 6.67083 20.125L6.66667 20V19.1666H8.33333V20H21.6667V11.1783L15.8833 16.9616C15.6646 17.1804 15.3725 17.3102 15.0636 17.3261C14.7547 17.3419 14.4508 17.2427 14.2108 17.0475L14.1158 16.9616L8.33333 11.1783V11.6666H6.66667V9.99998C6.66653 9.5795 6.82534 9.17451 7.11125 8.86619C7.39716 8.55787 7.78904 8.36902 8.20833 8.33748L8.33333 8.33331H21.6667ZM10 15.8333C10.221 15.8333 10.433 15.9211 10.5893 16.0774C10.7455 16.2337 10.8333 16.4456 10.8333 16.6666C10.8333 16.8877 10.7455 17.0996 10.5893 17.2559C10.433 17.4122 10.221 17.5 10 17.5H5.83333C5.61232 17.5 5.40036 17.4122 5.24408 17.2559C5.0878 17.0996 5 16.8877 5 16.6666C5 16.4456 5.0878 16.2337 5.24408 16.0774C5.40036 15.9211 5.61232 15.8333 5.83333 15.8333H10ZM20.4883 9.99998H9.51167L15 15.4883L20.4883 9.99998ZM9.16667 13.3333C9.37907 13.3335 9.58336 13.4149 9.73781 13.5607C9.89225 13.7065 9.9852 13.9058 9.99764 14.1178C10.0101 14.3298 9.9411 14.5386 9.80478 14.7015C9.66845 14.8644 9.47508 14.9691 9.26417 14.9941L9.16667 15H6.66667C6.45427 14.9997 6.24997 14.9184 6.09553 14.7726C5.94108 14.6268 5.84814 14.4275 5.83569 14.2155C5.82324 14.0034 5.89223 13.7947 6.02855 13.6318C6.16488 13.4689 6.35825 13.3642 6.56917 13.3391L6.66667 13.3333H9.16667Z",fill:"white"})),c.createElement("defs",null,c.createElement("clipPath",{id:"clip0_5976_46262"},c.createElement("rect",{width:20,height:20,fill:"white",transform:"translate(5 5)"})))),Ft=({name:t,width:s})=>e.jsx("div",{style:{width:s,height:s},className:"initials-image-atom",children:ba(t)}),$a=({show:t,handleClose:s,poc:r,type:i,url:m,fundRaisingObject:a})=>{const[n,o]=c.useState(""),[d,u]=c.useState(!1),p=async()=>{if(n!==""){try{u(!0);const v=(await le.functions().httpsCallable("sendEmailtoCPOC")({message:n,type:i,url:m,poc:r,fundRaisingObject:a})).data;_t(v),x()}catch(g){console.log(g.message),Q.error(g.message)}u(!1)}},x=()=>{s(),o("")},{name:N,role:j,image:b}=r;return e.jsx("div",{className:"fund-raising-point-of-contact-component",children:e.jsxs(Le,{show:t,onHide:s,size:"lg","aria-labelledby":"
1contained-modal-title-vcenter",className:"fund-raising-point-of-contact-modal",centered:!0,children:[e.jsxs(Le.Body,{className:"modal-content",children:[e.jsx(ja,{title:"Comments and Questions",handleClick:s}),e.jsxs("div",{className:"comments-container",children:[e.jsx("p",{children:"Drop a line with your feedback or questions or start a conversation about this project?"}),e.jsxs("div",{className:"cpoc-message-container",children:[e.jsxs("div",{className:"modal-manager-info",children:[b?e.jsx("img",{className:"manager-image",alt:"point of contact",src:b,loading:"lazy"}):e.jsx(Ft,{width:"70px",name:N}),e.jsxs("div",{className:"manager-details",children:[e.jsx("h3",{className:"manager-name",children:N}),e.jsx("span",{className:"manager-designation",children:j})]})]}),e.jsx("textarea",{value:n,onChange:g=>o(g.target.value),placeholder:"Start typing your message ...",rows:"8"})]})]})]}),e.jsxs(Le.Footer,{children:[e.jsx(ce,{small:!0,gray:!0,handleClick:x,children:"Close"}),e.jsx(ce,{small:!0,loading:d,disabled:d,handleClick:p,children:"Send"})]})]})})},Ma=({values:t})=>{const s=fe("currencySymbol");return e.jsxs("div",{className:"event-stats-component-container simple-tile-layout",children:[e.jsx(we,{title:"Total events",count:t.events||0}),e.jsx(we,{title:"Total no. of purchases",count:t.transactions||0}),e.jsx(we,{title:"Total tickets sold",count:t.tickets||0}),e.jsx(we,{title:"Total revenue",count:As(t.totalAmount,s)||0})]})},Ra=t=>{const s=t==null?void 0:t.startDate,r=t==null?void 0:t.endDate;return!s&&!r?"TBA":s&&!r?s.replaceAll("-","/"):!s&&r?r.replaceAll("-","/"):s===r?s.replaceAll("-","/"):`${s.replaceAll("-","/")} - ${r.replaceAll("-","/")}`},Ba=t=>{const s=t==null?void 0:t.startDate,r=t==null?void 0:t.endDate;return t!=null&&t.dateToBeAnnounced?"TBA":!s&&!r?"-":s&&!r?s.replaceAll("-","/"):!s&&r?r.replaceAll("-","/"):s===r?s.replaceAll("-","/"):`${s.replaceAll("-","/")} - ${r.replaceAll("-","/")}`},Lt=t=>t===!0?"Active":t===!1?"Completed":t==="archived"?"Cancelled":"-",Se={textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},Ua=()=>{const t=ve(),s=fe("currencySymbol")||"$";return c.useMemo(()=>[{id:"eventName",key:"eventName",title:"Event name",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding no-wrap",render:r=>e.jsx(bt,{onClick:()=>t(`/events/edit/${r.eventId}`),children:e.jsx(J,{sx:{width:"200px",...Se,cursor:"pointer"},children:r.eventName||"-"})})},{id:"date",key:"date",title:"Date",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>e.jsx(J,{sx:{width:"180px",...Se},children:Ra(r)})},{id:"totalTickets",key:"totalTickets",title:"Total tickets",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>e.jsx(J,{sx:{width:"120px"},children:r.totalTickets||0})},{id:"soldTickets",key:"soldTickets",title:"Sold",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>e.jsx(J,{sx:{width:"120px"},children:r.soldTickets||0})},{id:"remainingTickets",key:"remainingTickets",title:"Remaining",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>{const i=Number(r.totalTickets||0),m=Number(r.soldTickets||0),a=Math.max(i-m,0);return e.jsx(J,{sx:{width:"120px"},children:a})}},{id:"totalEventsProceeds",key:"totalEventsProceeds",title:"Total revenue",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>{const i=r.totalEventsProceeds?me(r.totalEventsProceeds):0;return e.jsx(J,{sx:{width:"140px"},children:`${s}${Me(i)}`})}},{id:"status",key:"status",title:"Status",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>e.jsx(J,{sx:{width:"120px"},children:Lt(r.status)})},{id:"lastUpdatedBy",key:"lastUpdatedBy",title:"Last updated by",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>e.jsx(J,{sx:{width:"180px",...Se},children:r.lastUpdatedBy||"-"})},{id:"lastUpdatedTime",key:"lastUpdatedTime",title:"Last updated on",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>e.jsx(J,{sx:{width:"180px"},children:r.lastUpdatedTime?Wt(r.lastUpdatedTime):"-"})}],[s,t])},Ha=()=>{const t=ve(),s=fe("currencySymbol")||"$";return c.useMemo(()=>[{id:"eventName",key:"eventName",title:"Event name",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding no-wrap",render:r=>{var i;return e.jsx(bt,{onClick:()=>t(`/events/create/${r.eventId||r.draftId}
1/?draftPublish`),children:e.jsx(J,{sx:{width:"200px",...Se,cursor:"pointer"},children:r.eventName||((i=r.campaign)==null?void 0:i.eventName)||"-"})})}},{id:"status",key:"status",title:"Status",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>{var i;return e.jsx(J,{sx:{width:"140px"},children:((i=r.status)==null?void 0:i.label)||Lt(r.status)})}},{id:"date",key:"date",title:"Date",sortable:!0,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>e.jsx(J,{sx:{width:"200px",...Se},children:Ba(r)})},{id:"action",key:"action",title:"Action",sortable:!1,defaultVisible:!0,headerClass:"header-cell",className:"normal-height normal-padding",render:r=>e.jsx(J,{sx:{width:"120px"},onClick:()=>t(`/events/create/${r.eventId||r.draftId}/?draftPublish`),children:e.jsx(Vs,{stroke:"#667085"})})}],[s,t])},Ga=()=>{const t=ve(),{allEvents:s,allEventDrafts:r}=X(S=>S.events),[i,m]=c.useState(""),[a,n]=c.useState({events:0,transactions:0,totalAmount:0,totalEventTickets:0}),[o,d]=c.useState(!1),[u,p]=c.useState({}),[x,N]=c.useState({search:"",statusFilter:"active",pagination:{page:0,hitsPerPage:10},sortKey:null,sortDirection:"ASC"}),[j,b]=c.useState({search:"",pagination:{page:0,hitsPerPage:10},sortKey:null,sortDirection:"ASC"}),[g,f]=c.useState(""),[l,v]=c.useState(""),h=S=>{const w=U=>{if(!U)return null;const L=new Date(`${U}T00:00:00`);return Number.isNaN(L.getTime())?null:L.getTime()},$=w(S.startDate);if($!=null)return $;const _=w(S.endDate);return _??0},C=S=>
1{const w=Number(S.totalTickets||0),$=Number(S.soldTickets||0);return Math.max(w-$,0)},T=c.useMemo(()=>[{value:"all",label:`All ${Yt("Event",!1)}`},{value:"active",label:"Active"},{value:"completed",label:"Completed"},{value:"archived",label:"Cancelled"}],[]),y=Ua(),E=Ha(),A=c.useMemo(()=>y.filter(S=>S.defaultVisible).map(S=>({key:S.key,title:S.title,render:S.render,sortable:S.sortable,className:S.className,headerClass:S.headerClass})),[y]),I=c.useMemo(()=>E.filter(S=>S.defaultVisible).map(S=>({key:S.key,title:S.title,render:S.render,sortable:S.sortable,className:S.className,headerClass:S.headerClass})),[E]);c.useEffect(()=>{const S=Is(m,"events");return()=>S},[]),c.useEffect(()=>{n(S=>({...S,events:(s==null?void 0:s.length)||0}))},[s]),c.useEffect(()=>{(async()=>{try{d(!0);const w=await Fs({title:"event-list-page"});w&&n($=>({...$,tickets:w.data.records[0].ticketPurchasedCount,transactions:w.data.records[0].transactionsCount,totalAmount:w.data.records[0].totalRevenue,latestTimeValueInPeriod:w.data.records[0].latestTimeValue}))}catch(w){console.error(w)}finally{d(!1)}})()},[]),c.useEffect(()=>{(async()=>{var w;try{const $=localStorage.getItem("token"),_="cido-infaque",U=`SELECT subtype, SUM(total) as totalEventsProceeds FROM all_transactions WHERE tenant_id = '${_}' AND transactionType = 'event' AND (deleted IS NULL OR deleted = 0) GROUP BY subtype`,L=await Ct.post(Ze,{query:U,tenant_id:_},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${$}`,"Access-Control-Allow-Origin":Ze}});if((w=L.data)!=null&&w.data){const P={};L.data.data.forEach(q=>{P[q.subtype]=q.totalEventsProceeds}),p(P)}}catch($){console.error("Error fetching per-event SQL amounts:",$)}})()},[]);const z=c.useMemo(()=>!Array.isArray(s)||!Object.keys(u).length?s:s.map(S=>({...S,totalEventsProceeds:u[S.eventId]??S.totalEventsProceeds??0})),[s,u]),M=c.useMemo(()=>{const w=(Array.isArray(z)?[...z]:[]).filter(L=>x.statusFilter==="all"?!0:x.statusFilter==="active"?L.status===!0:x.statusFilter==="completed"?L.status===!1:x.statusFilter==="archived"?L.status==="archived":x.statusFilter==="notVisible"?L.dontShowOnDonationPage===!0:!0),$=x.search?w.filter(L=>{var P;return(P=L.eventName)==null?void 0:P.toLowerCase().includes(x.search.toLowerCase())}):w,_=x.sortKey,U=x.sortDirection;if(_){const L=P=>{var q,H,G,xe;switch(_){case"eventName":return((q=P.eventName)==null?void 0:q.toLowerCase())||"";case"totalTickets":return Number(P.totalTickets||0);case"soldTickets":return Number(P.soldTickets||0);case"remainingTickets":return C(P);case"date":return h(P);case"totalEventsProceeds":return Number(P.totalEventsProceeds||0);case"status":{const he=P.status;return he===!0?2:he===!1?1:he==="archived"?0:-1}case"lastUpdatedBy":return((H=P.lastUpdatedBy)==null?void 0:H.toLowerCase())||"";case"lastUpdatedTime":return(G=P.lastUpdatedTime)!=null&&G.toMillis?P.lastUpdatedTime.toMillis():(xe=P.lastUpdatedTime)!=null&&xe.seconds?P.lastUpdatedTime.seconds:0;default:return P[_]}};$.sort((P,q)=>{const H=L(P),G=L(q);return typeof H=="string"&&typeof G=="string"?U==="ASC"?H.localeCompare(G):G.localeCompare(H):U==="ASC"?H>G?1:H<G?-1:0:H<G?1:H>G?-1:0})}return $},[z,x]),V=c.useMemo(()=>{const w=(Array.isArray(r)?r:[]).map(L=>({...L,...L.campaign})),$=j.search?w.filter(L=>{var q;return(L.eventName||((q=L.campaign)==null?void 0:q.eventName)||L.campaignName||"").toLowerCase().includes(j.search.toLowerCase())}):w,_=j.sortKey,U=j.sortDirection;if(_){const L=P=>{var q,H,G,xe,he,be,Ne,Ce;switch(_){case"eventName":return((q=P.eventName)==null?void 0:q.toLowerCase())||((G=(H=P.campaign)==null?void 0:H.eventName)==null?void 0:G.toLowerCase())||"";case"totalTickets":return Number(P.totalTickets||((xe=P.campaign)==null?void 0:xe.totalTickets)||0);case"soldTickets":return Number(P.soldTickets||((he=P.campaign)==null?void 0:he.soldTickets)||0);case"remainingTickets":return C(P);case"date":return h(P);case"status":return((Ne=(be=P.status)==null?void 0:be.label)==null?void 0:Ne.toLowerCase())||"";case"totalEventsProceeds":return Number(P.totalEventsProceeds||((Ce=P.campaign)==null?void 0:Ce.totalEventsProceeds)||0);default:return P[_]||""}};$.sort((P,q)=>{const H=L(P),G=L(q);return typeof H=="string"&&typeof G=="string"?U==="ASC"?H.localeCompare(G):G.localeCompare(H):U==="ASC"?H>G?1:H<G?-1:0:H<G?1:H>G?-1:0})}return $},[r,j]),Z=c.useMemo(()=>{const S=x.pagination.page*x.pagination.hitsPerPage,w=S+x.pagination.hitsPerPage;return M.slice(S,w)},[M,x.pagination]),W=c.useMemo(()=>{const S=j.pagination.page*j.pagination.hitsPerPage,w=S+j.pagination.hitsPerPage;return V.slice(S,w)},[V,j.pagination]),ae=()=>{t("/events/create")},ee=S=>{N(w=>({...w,statusFilter:S.value,pagination:{...w.pagination,page:0}}))},te=S=>{N(w=>({...w,search:S,pagination:{...w.pagination,page:0}}))},ie=S=>{b(w=>({...w,search:S,pagination:{...w.pagination,page:0}}))},de=S=>{N(w=>({...w,pagination:{...w.pagination,page:S}}))},k=S=>{b(w=>({...w,pagination:{...w.pagination,page:S}}))},F=S=>{N(w=>({...w,pagination:{page:0,hitsPerPage:(S==null?void 0:S.value)||10}}))},D=S=>{b(w=>({...w,pagination:{page:0,hitsPerPage:(S==null?void 0:S.value)||10}}))},B=(S,w)=>{N($=>({...$,sortKey:w==="default"?null:S,sortDirection:w==="default"?"ASC":w,pagination:{...$.pagination,page:0}}))},Y=(S,w)=>{b($=>({...$,sortKey:w==="default"?null:S,sortDirection:w==="default"?"ASC":w,pagination:{...$.pagination,page:0}}))};return e.jsxs("div",{className:"admin-all-events-list-page",children:[i&&a.latestTimeValueInPeriod&&!Os(a.latestTimeValueInPeriod,i)&&e.jsx(Ls,{title:"event-list-page",setRecords:n,loading:o,setLoa
1ding:d}),e.jsx(Kt,{crumbs:["Fundraising","Events"],onCrumbClick:()=>{}}),e.jsxs("div",{className:"admin-all-events-list-page-header",children:[e.jsx(Nt,{children:"Events"}),e.jsx("div",{className:"d-flex",children:e.jsx(ke,{variant:"contained",size:"large",onClick:ae,children:"New event"})})]}),e.jsx("div",{className:"campaign-stats-divider"}),e.jsx("div",{className:"event-stats",children:e.jsx(Ma,{values:a})}),e.jsxs("div",{className:"admin-all-events-list-page-body",children:[e.jsxs("div",{className:"campaign-table-container",children:[e.jsxs("div",{className:"campaign-table-search-container",children:[e.jsx(Ye,{searchValue:g,setSearchValue:f,onSearchChange:te}),e.jsx(Ps,{filterOptions:T,selectedValue:x.statusFilter,onFilterChange:ee,width:"175px"})]}),!o&&e.jsxs("div",{className:"campaign-results-count",children:[M.length," results"]}),M.length>0?e.jsx("div",{className:"admin-all-events-list-table-container",children:e.jsx(Ke,{columns:A,data:Z,loading:o,stickyHeader:!0,tableStyles:{borderRadius:"8px",border:"1px solid #EAECF0",maxHeight:"600px"},paginationComponent:e.jsxs(Oe,{display:"flex",direction:"row",justifyContent:"flex-end",alignItems:"center",gap:2,sx:{width:"100%",mt:2},children:[e.jsx(rt,{pageSize:x.pagination.hitsPerPage,options:[10,25,50],onPageSizeChange:F}),e.jsx(ot,{count:M.length,page:x.pagination.page+1,rowsPerPage:x.pagination.hitsPerPage,onPageChange:(S,w)=>de(w-1)})]}),sortKey:x.sortKey,sortDirection:x.sortDirection,handleSort:B})}):e.jsx(J,{sx:{textAlign:"center",padding:4,color:"#667085",fontSize:"16px"},children:x.search?"No events found matching your search":"No data available."})]}),Array.isArray(r)&&r.length>0&&e.jsx("div",{className:"draft-campaigns-title",children:e.jsx($s,{title:"Event drafts"})}),Array.isArray(r)&&r.length>0&&e.jsxs("div",{className:"campaign-table-container",children:[e.jsx("div",{className:"campaign-table-search-container",children:e.jsx(Ye,{searchValue:l,setSearchValue:v,onSearchChange:ie})}),!o&&e.jsxs("div",{className:"campaign-results-count",children:[V.length," results"]}),V.length>0?e.jsx("div",{className:"admin-all-draft-events-list-table-container",children:e.jsx(Ke,{columns:I,data:W,loading:o,stickyHeader:!0,tableStyles:{borderRadius:"8px",border:"1px solid #EAECF0",maxHeight:"600px"},paginationComponent:e.jsxs(Oe,{display:"flex",direction:"row",justifyContent:"flex-end",alignItems:"center",gap:2,sx:{width:"100%",mt:2},children:[e.jsx(rt,{pageSize:j.pagination.hitsPerPage,options:[10,25,50],onPageSizeChange:D}),e.jsx(ot,{count:V.length,page:j.pagination.page+1,rowsPerPage:j.pagination.hitsPerPage,onPageChange:(S,w)=>k(w-1)})]}),sortKey:j.sortKey,sortDirection:j.sortDirection,handleSort:Y})}):e.jsx(J,{sx:{textAlign:"center",padding:4,color:"#667085",fontSize:"16px"},children:"No event drafts found matching your search"})]})]})]})},za=()=>{const[t,s]=c.useState(!1),[r,i]=c.useState(!1),[m,a]=c.useState(null),[n,o]=c.useState(!1),[d,u]=c.useState(!1),{event:p,setEvent:x,section:N}=c.useContext(R),j=14/5,{mediaLibrary:b}=X(E=>E.mediaLibrary),g=b.filter(E=>E.url===p.cover),f=E=>{if(E.name.toLowerCase().match(/\.(jpg|jpeg|png|gif)$/)){const A=new FileReader;A.readAsDataURL(E),A.onloadend=()=>{a(A.result),i(!0)}}else return Q.error("Please select a valid image format"),l(),!1},l=E=>{x(A=>({...A,cover:null})),inputRef.current.value=null},v=()=>{u(!0)},h=()=>{u(!1)},C=E=>{x({...p,cover:E.url}),a(E.url),i(!0)},T=E=>{const A=document.createElement("canvas"),I=A.getContext("2d");A.width=1400,A.height=500;const z=new Image;z.src=E,z.onload=async()=>{I.drawImage(z,0,0,1400,500);const M=A.toDataURL("image/jpeg"),V=y(M),Z=`resized_${Date.now()}.jpg`,W=new File([V],Z,{type:"image/jpeg"}),ae=le.storage().ref(`media_library/${Z}`);ae.put(W).on("state_changed",te=>{},te=>{console.error("Upload error:",te)},async()=>{const te=await ae.getDownloadURL();x(k=>({...k,cover:te}));const de=le.functions().httpsCallable("manageMediaLibrary-manageMediaLibrary");try{await de({type:"updateWithCroppedURL",docId:g[0].id,croppedUrl:te,fundraiser:p.eventName})}catch(k){console.error("Error adding cropped URL to media library:",k)}}),a(null)}};function y(E){const A=E.split(","),I=A[0].match(/:(.*?);/)[1],z=atob(A[1]);let M=z.length;const V=new Uint8Array(M);for(;M--;)V[M]=z.charCodeAt(M);return new Blob([V],{type:I})}return e.jsxs("div",{children:[e.jsxs("div",{className:`event-cover-view-create cursor-pointer ${p.cover?"no-border":""}`,children:[e.jsxs("div",{className:"event-cover-view-container",children:[e.jsxs("div",{className:`project-image-container ${p!=null&&p.cover?"present":""}
1`,children:[e.jsx(je,{setError:s,datatest:"event-logo",id:"cover",width:"200px",edit:!0,file:p.cover,setFile:f,setEvent:x,openDialog:v}),n&&e.jsxs("div",{className:"alert-message",children:[e.jsxs("div",{className:"title",children:["Are you happy with the image?",e.jsx(_s,{onClick:()=>o(!1),alt:"close-are-you-happy"})]}),e.jsxs("div",{className:"description",children:["This is how your image will be displayed to the contacts. You can proceed if you are happy with the image otherwise try uploading it with the following dimensions:",e.jsx("span",{children:" 1400 px width  500 px height"})]})]}),p.cover?"":e.jsx("div",{className:"text-center subtext",children:e.jsx("span",{children:" 1400 px width  500 px height"})})]}),e.jsx("div",{className:"error-red",children:t})]}),e.jsxs("div",{className:"subtext",children:[e.jsx("span",{className:"warning",children:"Note:  "}),e.jsxs("span",{className:"normal",children:[" ","Images other than these dimensions may not look good."]})]})]}),e.jsx(Ws,{show:r,onHide:()=>{i(!1)},imageSrc:m,onImageCropped:T,aspectRatio:j}),e.jsx(At,{open:d,handleClose:h,handleSelectFileFromLibrary:C,isInMediaLibrary:!0}),e.jsx("div",{className:"general-info-section-footer",children:!ge(window.location.pathname)&&e.jsx(ue,{section:N,showSkip:!0})})]})},qa="This should be a tangible statement.For example raising funds for meals for a hundred families in need in Western Toronto.",_a=()=>{const[t,s]=K.useState(null),{allCauseProjects:r,activeCampaignsList:i}=X(g=>g.campaign);fe("causeName");const{section:m,event:a,eventErrors:n,setEvent:o,setEventErrors:d}=c.useContext(R),{CampaignServiceData:u}=Zt();K.useEffect(()=>{const g=r.filter(f=>f.cause==="general");if(g.length>0){const f={label:g[0].campaignName,value:g[0].campaignId},l="causes";o(v=>v.causes[0].value?v:{...v,[l]:[f]})}},[o,r,a]),K.useEffect(()=>{var h,C;const g=(C=(h=a==null?void 0:a.causes)==null?void 0:h[0])==null?void 0:C.value;if(!g||!Array.isArray(u))return;const f=u.find(T=>Array.isArray(T.innerval)&&T.innerval.some(y=>y.campaignId===g));if(!f)return;const l=f.innerval.find(T=>T.campaignId===g);if(!l)return;const v={label:f.value,value:l.campaignName,idToStore:l.campaignId};s(T=>(T==null?void 0:T.idToStore)&&T.idToStore===v.idToStore?T:v)},[u,a==null?void 0:a.causes]);const p=(g,f)=>{o({...a,eventSummary:g})},x=g=>{d({...n,eventSummary:g})},N=g=>{o({...a,eventName:g})},j=g=>{d({...n,eventName:g})},b=(g,f,l)=>{if(s(g),f==="project"){let v={causes:l.causes,linkedCampaignId:l.campaignId};o({...a,causes:[{...v.causes}],linkedCampaignId:v.linkedCampaignId})}else if(f==="cause"){let v={label:l.campaignName,value:l.campaignId};o({...a,causes:[{...v}],linkedCampaignId:null})}};return e.jsx("div",{className:"event-basic-section-admin-edit-component",children:e.jsxs("div",{className:"event-basic-section-admin-edit-container",children:[e.jsx(se,{type:"h3"}),e.jsx("div",{className:"event-basic-section-info-container",children:e.jsxs("div",{className:"event-basic-section-impact-container",children:[e.jsx(Ie,{required:!0,type:"text",characterCount:60,"data-test":"event-name",label:"Event Name",value:a.eventName,setValue:g=>N(g),setError:j,error:n.eventName,regularExpression:Jt}),e.jsx(Ue,{help:qa,required:!0,type:"text","data-test":"short-summary",label:"impact Statement",value:a.eventSummary,setValue:g=>p(g),setError:x,error:n.eventSummary,characterCount:400})]})}),e.jsxs("div",{className:"service-info subsection",children:[e.jsx(se,{type:"h3",children:"Please select the fundraiser linked to this event."}),e.jsx("div",{className:"content causes-content cause-area",children:e.jsx(Ys,{onSelectChange:b,defaultSelectedOption:t,onlyCause:!0})})]}),e.jsx("div",{className:"general-info-section-footer",children:!ge(window.location.pathname)&&e.jsx(ue,{hideBack:!0,disabled:m===1?!a.eventName||!a.eventSummary||!a.causes:!1,section:m})})]})})},Wa=()=>{const{event:t,section:s,setSection:r,submitDraft:i,eventErrors:m}=c.useContext(R),a=o=>{let d=!1;for(let u=o;u>0;u--)Je(u,t,m)||(d=!0);(!d||o<s)&&r(o+1)},n=o=>{let d=!1;for(let u=o;u>0;u--)Je(u,t,m)||(d=!0);return d};return e.jsx("div",{className:"event-section-header-component",children:s===8?e.jsxs("div",{className:"preview-header",children:[e.jsxs("div",{className:"back-text",onClick:()=>r(7),children:[e.jsx(Ks,{}),"  Back to Editing"]}),e.jsx("div",{className:"",children:"Preview and publish your event."}),e.jsx(ce,{small:!0,handleClick:i,gray:!0,children:"Save Draft"})]}):e.jsxs("div",{className:"preview-header",children:[e.jsx("div",{className:"d-flex",children:Array(7).fill().map((o,d)=>e.jsxs("div",{onClick:()=>a(d),className:`project-bar-container ${d+1<s?"active":""} ${d+1===s?"current":n(d)&&"disabled"} 2 3 4 `,children:[e.jsx("div",{className:"number",children:d+1}),d+1!==7&&e.jsx("div",{className:"bar"})]},d))}),e.jsx(ce,{small:!0,handleClick:i,gray:!0,children:"Save Draft"})]})})},Ya=()=>{const{section:t,event:s,setEvent:r,eventErrors:i,setEventErrors:m}=c.useContext(R),a=X(l=>l.adminUserProfile.admins),[n,o]=c.useState(!1),[d,u]=c.useState(!1),p=(l,v,h)=>{const C={...s.pointOfContact};if(h&&v==="name"||v==="role"){if(!Qe(l,h)){m({...i,name:"Invalid name"});return}}else if(h&&v==="phone"&&!Qe(l,h)){m({...i,businessPhone:"Invalid phone number format"});return}C[v]=l,r({...s,pointOfContact:{...C}})},x=(l,v)=>{const h={...i.pointOfContact},C={...s.pointOfContact,email:l,name:v};r({...s,pointOfContact:{...C}}),m({...i,pointOfContact:{...h,email:!1,name:!v}})},N=(l,v)=>{const h={...i.pointOfContact};h[v]=l,m({...i,pointOfContact:h})},j=async l=>{if(!l)return;const h=le.functions().httpsCallable("uploadMediaToFirebaseStorage"),C=new FileReader;C.readAsDataURL(l),C.onloadend=async function(){var A;const T=C.result,y=[T];r(I=>({...I,pointOfContact:{...I.pointOfContact,image:T}}));const E=await h({images:y});if((A=E==null?void 0:E.data)!=null&&A.success){const I=E.data.imageUrl;r(z=>({...z,pointOfContact:{...z.pointOfContact,image:I[0]}}))}}},b=()=>{u(!0)},g=()=>{u(!1)},f=l=>{r(v=>({...v,pointOfContact:{...v.pointOfContact,image:l.url}})),u(!1)};return e.jsxs("div",{className:"project-contact-section-component",children:[e.jsx("div",{className:"contact-section-content",children:e.jsxs("div",{className:"basic-info",children:[e.jsxs("div",{className:"content",children:[e.jsx(Zs,{required:!0,label:"Email",dataTest:"poc-email",value:s.pointOfContact.email,errorMessage:"Email is required in the right format",error:i.pointOfContact.email,setError:l=>N(l,"email"),setValue:l=>p(l,"email"),handleSearch:(l,v)=>x(l,v),options:a}),e.jsx(Ie,{required:!0,label:"Name","data-test":"project-name",value:s.pointOfContact.name,error:i.pointOfContact.name,setValue:l=>p(l,"name","text"),setError:l=>N(l,"name")}),e.jsx(Ie,{label:"Role","data-test":"project-name",value:s.pointOfContact.role,error:i.pointOfContact.role,setValue:l=>p(l,"role","text"),setError:l=>N(l,"role")}),e.jsx(Ie,{label:"Mobile Phone","data-test":"project-name",type:"number",error:i.pointOfContact.businessPhone,value:s.pointOfContact.businessPhone,setValue:l=>p(l,"businessPhone","number"),setError:l=>N(l,"businessPhone")})]}),e.jsx("div",{className:"image-info subsection",children:e.jsxs("div",{className:"content",children:[e.jsxs("div",{className:"image-content-container",children:[e.jsx(je,{setError:o,datatest:"cpoc-image",width:"120px",edit:!0,file:s.pointOfContact.
4image,setFile:l=>j(l),handleDeleteImage:()=>p(null,"image"),openDialog:b}),e.jsx(At,{open:d,handleClose:g,handleSelectFileFromLibrary:f,isInMediaLibrary:!0})]}),e.jsx(se,{type:"h5",children:"Upload Profile Image"}),"100 px width â 100 px height",e.jsx("div",{className:"error-red",children:n})]})})]})}),e.jsx("div",{className:"general-info-section-footer",children:!ge(window.location.pathname)&&e.jsx(ue,{section:t})})]})},Ka=()=>{const{setDescriptionSelection:t,descriptionSelection:s,setDescriptionSection:r,descriptionError:i,event:m,setEvent:a,setDescriptionError:n}=c.useContext(R),[o,d]=c.useState(null),[u,p]=c.useState(!1),[x,N]=c.useState(0),j=fe("descriptionPrompt"),[b,g]=c.useState(!1),f=(y,E)=>{y==="tone"&&s.demographic||y==="demographic"&&s.tone||t({...s,[E]:y})},l=y=>{n(y)},v=async()=>{p(!0);try{const y=window.location.href,E=`${j||Xt.desc} 5 6Description: ${s.description} 7 Target Demographic: ${s.demographic?s.demographic:"All Demographics"} 8 Tone: ${s.tone?s.tone:"Formal"}`,I=await es.httpsCallable("thirdPartyApis-getResponseFromChatGpt")({chatInfo:E,actualUrl:y});I.data.success&&t({...s,auto:I.data.description})}catch(y){console.log(y.message)}p(!1)};c.useEffect(()=>{g(i===!1)},[i]);const h=()=>{d(y=>(clearInterval(y),null))},C=c.useCallback(()=>{let y=0;d(setInterval(()=>{y=y+1,N(y),y===3&&h()},3e3))},[]);c.useEffect(()=>{u?C():h()},[u,C]);const T=()=>{s!=null&&s.description&&a({...m,description:s.description||""}),r(3)};return e.jsxs("div",{className:"event-add-description-component",children:[e.jsxs("div",{className:"event-description-section-content",children:[e.jsx("div",{className:"basic-info",children:e.jsx("div",{className:"content",children:e.jsx(Ue,{required:!0,min:150,hideOnFocus:!0,title:"Description",label:"Start Typing..",characterCount:4e3,"data-test":"project-description",regularExpression:yt,setError:y=>l(y),value:s==null?void 0:s.description,error:i,setValue:y=>f(y,"description"),errorMessage:"Please provide a minimum of 150 characters for description "})})}),e.jsx(Js,{skip:T,data:s,handleTone:y=>f(y,"tone"),handleDemographic:y=>f(y,"demographic")})]}),e.jsx("div",{className:"general-info-section-footer",children:!ge(window.location.pathname)&&e.jsx(ue,{step:Qt[x],desc:!0,disabled:!b,onNext:v,loading:u})})]})},Za=()=>{const{setDescriptionSelection:t,descriptionSelection:s,event:r,setEvent:i}=c.useContext(R),[m,a]=c.useState(!1),n=d=>{const u=d===1?s.description:s.auto;i({...r,description:u}),t({...s,selection:d})};c.useEffect(()=>{s.selection?a(!0):a(!1)},[s]);const o=()=>{i({...r,description:s.description}),t({...s,selection:1})};return e.jsxs("div",{className:"event-description-with-ai-component",children:[e.jsx("div",{className:"description-section-content",children:e.jsx("div",{className:"basic-info",children:e.jsxs("div",{className:"content",children:[e.jsxs("div",{className:"original",children:[e.jsx("textarea",{readOnly:!0,className:`box ${s.selection===1?"active":""}`,onClick:()=>n(1),children:s.description}),e.jsx(ct,{onClick:()=>n(1),active:s.selection===1,children:"Use Original"})]}),e.jsxs("div",{className:"ai",children:[e.jsx("textarea",{readOnly:!0,onClick:()=>n(2),className:`box ${s.selection===2?"active":""}`,children:s.auto||s.auto.response}),e.jsx(ct,{onClick:()=>n(2),active:s.selection===2,children:"Use AI Generated"})]})]})})}),e.jsxs("div",{children:[e.jsxs("div",{className:"note",children:[e.jsx("span",{children:"Note:"})," Whichever description you select you can edit it further on the next screen"]}),e.jsx("div",{className:"general-info-section-footer",children:!ge(window.location.pathname)&&e.jsx(ue,{desc:!0,onSkip:o,disabled:!m,showSkip:!0})})]})]})},Ja=()=>{const{event:t,setEvent:s,eventErrors:r,setEventErrors:i}=c.useContext(R),m=n=>{s({...t,description:n})},a=n=>{let o=0;n||o++,n.match(yt)||o++,i({...r,description:o>0})};return e.jsxs("div",{className:"finalize-project-description-component",children:[e.jsx("div",{className:"description-section-content",children:e.jsx("div",{className:"basic-info",children:e.jsx("div",{className:"content",children:e.jsx(Qs,{characterCount:4e3,setError:a,dataTest:"context-description",value:t.description||"",setValue:m,required:!0})})})}),e.jsx("div",{className:"general-info-section-footer",children:!ge(window.location.pathname)&&e.jsx(ue,{desc:!0,disabled:!t.description})})]})},Qa=()=>{const{descriptionSection:t,setDescriptionSection:s}=c.useContext(R);return e.jsx("div",{className:"project-description-section-component",children:{1:e.jsx(Ka,{descriptionSection:t,setDescriptionSection:s}),2:e.jsx(Za,{descriptionSection:t,setDescriptionSection:s}),3:e.jsx(Ja,{descriptionSection:t,setDescriptionSection:s})}[t]})}
8,Xa=()=>{const{event:t,setEvent:s,section:r}=c.useContext(R),i=n=>new Promise((o,d)=>{if(typeof n=="string"&&n.startsWith("data:image")){o(n);return}const u=new FileReader;u.readAsDataURL(n),u.onload=()=>o(u.result),u.onerror=p=>d(p)}),m=async(n,o)=>{var g;if((n==null?void 0:n.length)>0&&n[0]===null)return;const d=n.filter(f=>!(typeof f=="string"&&f.startsWith("http"))),u=n.filter(f=>typeof f=="string"&&f.startsWith("http")),p=await Promise.all(d.map(async f=>await i(f))),x=[...u,...p];if(s({...t,[o]:x}),d.length===0)return;const b=await le.functions().httpsCallable("uploadMediaToFirebaseStorage")({images:p});if((g=b==null?void 0:b.data)!=null&&g.success){const f=b.data.imageUrl,l=[...u,...f];s({...t,[o]:l})}else console.error("Error uploading images:",b.data.message)},a=n=>{const o=[...t.eventContextImages];o.splice(n,1),s({...t,eventContextImages:o})};return e.jsxs("div",{children:[e.jsx("div",{className:"event-context-section-images-component",children:e.jsx("div",{className:"context-section-content",children:e.jsx("div",{className:"context-images",children:e.jsx(Dt,{gallery:!0,count:10,setImages:n=>m(n,"eventContextImages"),images:t.eventContextImages,deleteImage:a})})})}),e.jsx("div",{className:"general-info-section-footer",children:!ge(window.location.pathname)&&e.jsx(ue,{section:r,showSkip:!0})})]})},en=t=>{const s=Re(),[r,i]=K.useState([]),{causeProjectsById:m}=X(d=>d.campaign),a=He((t==null?void 0:t.id)||s.id);function n(d,u){return d&&d.causes&&d.causes[0]&&d.causes[0].value&&u[d.causes[0].value]?u[d.causes[0].value].campaignName:""}const o=(d,u,p,x)=>{const N=v=>{let h;if(v instanceof Date)h=v;else if(typeof v=="string")h=new Date(`${v}T00:00:00`);else return"Invalid Date";return h.setHours(10,0,0,0),h.toLocaleDateString("en-US",{timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit"})},j=N(d),[b,g,f]=j.split("/"),l=N(p);return`${j} - ${l} ${u} - ${x} `};return K.useEffect(()=>{var u;const d=[{id:1,title:t&&t.eventName||"Name your event",description:"Give your event a suitable name and write an introductory tag line.",values:{"Impact Statement":t&&t.eventSummary||"","Linked To Fundraiser":n(t,m)},initialValues:{eventName:a&&a.eventName||"",eventSummary:a&&a.eventSummary,"Linked To Fundraiser":a&&a.causes}},{id:2,title:"When and where this event is happening",description:"Enter basic details about the event date and time so the event attendees.",values:{endDate:"",Date:o(t.startDate,t.startTime,t.endDate,t.endTime),startTime:"",timezone:t&&((u=t==null?void 0:t.timezone)==null?void 0:u.label)||"",eventTypeOnline:"",location:t&&t.location||"",onlineLink:"","Event Mode":t&&t.eventTypeOnline?"This is Online Event":"This is onsite event"},initialValues:{startDate:a&&a.startDate||"",endDate:a&&a.endDate||"",startTime:a&&a.startTime||"",endTime:a&&a.endTime||"",timezone:a&&(a==null?void 0:a.timezone)||t.timezone,eventTypeOnline:"",location:a&&a.location||"",onlineLink:""}},{id:3,title:"Point of contact details",optional:!0,description:"Details of the person who is responsible for managing this event. i.e. providing updates to attendees and addressing their queries etc.",values:{},initialValues:{pointOfContact:a&&a.pointOfContact||t.pointOfContact}},{id:4,title:"Write Event Description",description:"Describe your event manually or use AI to write a targeted description.",values:{Description:t&&t.description?ts(t.description):""},initialValues:{description:a&&a.description}},{id:5,title:"Get event tickets ready for purchase",description:"Create tickets for your event whether it is free, paid or ticket groups.",values:{},initialValues:{eventCapacity:a&&a.eventCapacity||"",tickets:a&&a.tickets||t.tickets,packages:a&&a.packages||t.packages}},{id:6,title:"Upload Event Cover Image",optional:!0,description:"Have an banner image in hand ? Give your event a memorable look.",values:{},initialValues:{cover:a&&a.cover||""}},{id:7,title:"Provide any additional images to contextualize the Event",optional:!0,description:"Use this space to add any images of speakers or show preparation on ground. ",values:{},initialValues:{eventContextImages:a&&a.eventContextImages||[]}}];i(d)},[t,m,a]),r},tn=({title:t,description:s,id:r,activeForm:i,optional:m})=>{var o;const{validationState:a}=c.useContext(R),n=(o=a.find(d=>d.id===r))==null?void 0:o.isValid;return e.jsxs("div",{className:"event-header-tiles-component",children:[e.jsxs("div",{className:"heading mt-4",children:[e.jsxs("div",{className:"d-flex align-items-center ",children:[e.jsxs(se,{type:"h4",children:[r,". ",r===1?"Describe Your Event":t]}),n===!1&&r!==5&&r!==6&&r!==7&&e.jsx("div",{className:"ml-3 mb-1",children:e.jsx(Be,{})})]}),m&&e.jsx("span",{className:"optional",children:"(Optional)"})]}),e.jsx("div",{className:"body",children:e.jsx("span",{className:"title",children:s})})]})},sn=()=>{const t=ve(),{section:s,event:r,setEvent:i,submitFunction:m}=c.useContext(R),n=en(r).find(p=>p.id===s),{displayName:o,email:d}=X(p=>p.user.currentUser),u=()=>{m({publish:!0})};return c.useEffect(()=>{i({...r,pointOfContact:{email:d,name:o}})},[]),e.jsxs("div",{className:"create-event-template-component",children:[e.jsx(ss,{crumbs:["Fundraising","Events",r.eventName||"New Event"],onCrumbClick:p=>{t("/events/all-events")}}),e.jsx("div",{className:"create-project-header-wrapper",children:e.jsx(Nt,{children:r.eventName||"New Event"})}),e.jsx("span",{className:"divider"}),e.jsxs("div",{className:"sections-container",children:[e.jsx(Wa,{}
8),n&&e.jsx(tn,{title:n.title,description:n.description,optional:n.optional,id:n.id,activeForm:s}),e.jsx("div",{className:"event-section-content",children:e.jsx("div",{className:"event-basic-section-admin-edit-wrapper",children:{1:e.jsx(_a,{}),2:e.jsx(Bs,{}),3:e.jsx(Ya,{}),4:e.jsx(Qa,{}),5:e.jsx(Rs,{}),6:e.jsx(za,{}),7:e.jsx(Xa,{}),8:e.jsxs("div",{className:"section-eight",children:[e.jsx("h1",{children:"Your Public Page is Ready!"}),e.jsx("h2",{children:"Tap below to preview how it appears to your contacts."}),e.jsx("button",{onClick:()=>{const p=r;sessionStorage.setItem("PreviewData",JSON.stringify(p)),window.open("/previews?header=no-header","_blank")},className:"preview-event-button",children:"Preview Event"}),e.jsx("div",{className:"general-info-section-footer",children:e.jsx(ue,{publish:!0,section:s,onPublish:u})})]})}[s]})})]})]})},an=({preview:t,setPreview:s,draftButton:r,edited:i,setEdited:m,initialEvent:a,isPublishEnabled:n})=>{var Ne,Ce,Ge,ze,qe,_e;const{event:o,setMailData:d,setEvent:u,setValidationState:p,submitFunction:x,submitDraft:N,updated:j,validationFunction:b,setActiveForm:g,setEventErrors:f,eventErrors:l}=c.useContext(R),[v,h]=c.useState(!1),[C,T]=c.useState(o.status||""),[y,E]=c.useState(!1),[A,I]=c.useState(!1),[z,M]=c.useState(!1),[V,Z]=c.useState(!1),[W,ae]=c.useState(!1),[ee,te]=c.useState(null),[ie,de]=c.useState(""),[k,F]=c.useState(null),[D,B]=c.useState("");K.useEffect(()=>{var O;if((O=o==null?void 0:o.timezone)!=null&&O.iana){const pe=De.tz(new Date,o.timezone.iana).format("HH:mm");B(pe),de(pe)}},[(Ne=o==null?void 0:o.timezone)==null?void 0:Ne.iana]);const Y=c.useRef(null),[S,w]=c.useState(!1),$=()=>{h(!1),T(o.status||""),C.label==="Completed"?(te(ee||null),de(ie||"")):C.label==="Cancelled"&&(F(k||null),B(D||""))},_=V&&(!ee||!ie)||W&&(!k||!D)||!o.adminMsg,U=()=>{if(!o.adminMsg){E(!0);return}const O=(pe,Ee,Fe)=>{if(!pe||!Ee||!Fe)throw new Error("Date, time, and timezone are required.");const $t=`${De(pe).format("YYYY-MM-DD")}T${Ee}`;return De.tz($t,Fe).format()},ne=o.timezone.iana;u({...o,status:C,statuscompletionDate:V&&C.label==="Completed"?O(ee,ie,ne).split("T")[0]:"",statuscompletionTime:V&&C.label==="Completed"?O(ee,ie,ne).split("T")[1]:"",statuscancellationDate:W&&C.label==="Cancelled"?O(k,D,ne).split("T")[0]:"",statuscancellationTime:W&&C.label==="Cancelled"?O(k,D,ne).split("T")[1]:"",statuscompletedschedule:V&&C.label==="Completed"?A:!1,statuscancelledschedule:W&&C.label==="Cancelled"?z:!1}),$()},L=(O,ne)=>{h(!0),T(O)},P=(O,ne)=>{f({...l,[ne]:O})},q=()=>{u(a||kt),p([]),g(null),m(!1)},H=()=>{b().status&&s(!0)},G=()=>{o.eventId&&window.open(`/preview/${o.eventId}?eventPreview=true&campaignPreview=false&header=no-header`,"_blank")},xe=O=>{Z(O.target.checked)},he=O=>{ae(O.target.checked)},be=(O,ne,pe)=>{if(!O||!ne||!pe)return"Invalid date/time";const Ee=`${O}T${ne}`;return De.tz(Ee,pe).format("YYYY-MM-DD [at] h:mm A")};return e.jsx("div",{className:"admin-manage-events-header-component",children:e.jsxs("div",{className:"fix-header",children:[e.jsxs("div",{className:"og-header",children:[e.jsxs("div",{className:"event-left-heading",children:[e.jsxs("div",{className:"events-header-left-section",children:[e.jsx(jt,{"data-test":"events",to:"/events/all-events",children:"Events"}),e.jsx(Xs,{}),e.jsx(se,{type:"h4",children:o.eventName?o.eventName:"New Event"})]}),e.jsxs("div",{children:[o.completedDate&&o.completedTime&&e.jsxs("div",{className:"scheduled-text",children:["Schedule for completion:"," ",be(o.completedDate,o.completedTime,(Ce=o.timezone)==null?void 0:Ce.iana),"Â Â Â Â ",(Ge=o.timezone)==null?void 0:Ge.label]}),o.cancelledDate&&o.cancelledTime&&e.jsxs("div",{className:"scheduled-text",children:["Schedule for cancellation:"," ",be(o.cancelledDate,o.cancelledTime,(ze=o.timezone)==null?void 0:ze.iana),"Â Â Â Â ",(qe=o.timezone)==null?void 0:qe.label]})]})]}),e.jsxs("div",{className:"events-header-right-section",children:[e.jsxs("div",{className:"header-controls",children:[t?e.jsx(ce,{"data-test":"draft",gray:!0,handleClick:()=>s(!1),children:"Back to editing"}):((_e=o.eventId)==null?void 0:_e.length)>0?null:e.jsx("button",{id:"preview-btn","data-test":"events",onClick:()=>H(),children:"Preview"}),e.jsxs("div",{className:"status-field",children:[e.jsx("button",{"data-tip":"Get a preview of the public-facing Events page.","data-for":"publish-tooltip",id:"preview-btn","data-test":"events",onClick:G,children:"Preview"}),e.jsx(Xe,{id:"publish-tooltip",place:"bottom",type:"info",effect:"solid",backgroundColor:"black",textColor:"white",className:"tooltip"})]}),e.jsxs("div",{className:"status-field",children:[e.jsx(ea,{"data-test":"status-dropdown","data-tip":" You can change the status of the Event and mark it as Active/Cancelled or Completed","data-for":"status-tooltip",option:o.status,setOption:O=>L(O),options:as,setError:O=>P(O,"status"),error:l.status,required:!0}),e.jsx(Xe,{id:"status-tooltip",place:"bottom",type:"info",effect:"solid",backgroundColor:"black",textColor:"white",className:"tooltip"})]}),r&&e.jsx(ce,{"data-test":"draft",containerClass:"draft",handleClick:()=>N(),gray:!0,children:"Save Draft"}),e.jsx("div",{ref:Y,children:e.jsx(ce,{"data-test":"publish",handleClick:()=>{x({publish:!0})},disabled:!n,children:"Publish"})})]}),e.jsx(Ms,{modalType:"event",setShow:w,publish:!1,submitFunction:x,setMailData:d,onHide:()=>w(!1),show:S})]}),e.jsxs(ns,{show:v,handleClose:$,header:!0,headerTitle:"Message for your attendees",cancelButtonText:"Cancel",submitButton:!0,submitButtonFunction:U,submitButtonText:"Submit",submitButtonLoading:!1,submitButtonDisabled:_,children:[e.jsx(Ue,{value:o.adminMsg,setValue:O=>{u({...o,adminMsg:O})},label:"Message",setError:E,error:y,required:!0}),(C.label==="Completed"||C.label==="Cancelled")&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"statusdateandtime",children:[C.label==="Completed"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"labeleventcompletion",children:[e.jsx("input",{style:{width:"16px",height:"16px"},type:"checkbox",checked:V,onChange:xe}),e.jsx("span",{className:"eventcompletion-text",children:"Schedule for event completion"})]}),e.jsxs("div",{className:"dateandtime",style:{display:"flex",gap:"10px"},children:[e.jsxs("div",{className:"datetext-datefield",disabled:!V,children:[e.jsx("span",{className:"date-text",children:"Date"}),e.jsx("div",{children:e.jsx(lt,{"data-test":"enddate-input",date:ee,placeholder:"Click to select a date",setDate:O=>{te(O),I(!0)},error:l.completionDate,setError:O=>P(O,"completionDate"),required:!0,defaultFocus:!0,disabled:!V})})]}),e.jsxs("div",{className:"timetext-timefield",disabled:!V,children:[e.jsx("span",{className:"timetext",children:"Time"}),e.jsx("input",{id:"completedTimeInput",type:"time",value:ie,onChange:O=>{de(O.target.value),I(!0)},disabled:!V})]})]})]}),C.label==="Cancelled"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"labeleventcancelled",children:[e.jsx("input",{style:{width:"16px",height:"16px"},type:"checkbox",checked:W,onChange:he}),e.jsx("span",{className:"eventcancel-text",children:"Schedule for event cancellation"})]}),e.jsxs("div",{className:"canceldateandtime",children:[e.jsxs("div",{className:"canceldatetext-datefield",disabled:!W,children:[e.jsx("span",{className:"canceldate-text",children:"Date"}),e.jsx("div",{children:e.jsx(lt,{"data-test":"cancelled-date-input",date:k,placeholder:"Click to select a date",setDate:O=>{F(O),M(!0)},error:l.completionDate,setError:O=>P(O,"completionDate"),required:!0,defaultFocus:!0,disabled:!W})})]}),e.jsxs("div",{className:"canceltimetext-timefield",disabled:!W,children:[e.jsx("span",{className:"canceltimetext",children:"Time"}),e.jsx("input",{id:"cancelledTimeInput",type:"time",value:D,onChange:O=>{B(O.target.value),M(!0)},disabled:!W})]})]})]})]})})]})]}),e.jsx(ta,{email:o.emailSent===!1,edited:i,updated:j,handleDiscardChanges:q,event:!0,eventData:o})]})})},mt=t=>
8c.createElement("svg",{width:20,height:20,viewBox:"0 0 18 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("path",{d:"M17.125 5.75C17.2908 5.75 17.4497 5.68415 17.5669 5.56694C17.6842 5.44973 17.75 5.29076 17.75 5.125V2C17.75 1.66848 17.6183 1.35054 17.3839 1.11612C17.1495 0.881696 16.8315 0.75 16.5 0.75L1.5 0.75C1.16848 0.75 0.850537 0.881696 0.616116 1.11612C0.381696 1.35054 0.25 1.66848 0.25 2L0.25 5.125C0.25 5.29076 0.315848 5.44973 0.433058 5.56694C0.550268 5.68415 0.70924 5.75 0.875 5.75C1.20652 5.75 1.52446 5.8817 1.75888 6.11612C1.9933 6.35054 2.125 6.66848 2.125 7C2.125 7.33152 1.9933 7.64946 1.75888 7.88388C1.52446 8.1183 1.20652 8.25 0.875 8.25C0.70924 8.25 0.550268 8.31585 0.433058 8.43306C0.315848 8.55027 0.25 8.70924 0.25 8.875L0.25 12C0.25 12.3315 0.381696 12.6495 0.616116 12.8839C0.850537 13.1183 1.16848 13.25 1.5 13.25H16.5C16.8315 13.25 17.1495 13.1183 17.3839 12.8839C17.6183 12.6495 17.75 12.3315 17.75 12V8.875C17.75 8.70924 17.6842 8.55027 17.5669 8.43306C17.4497 8.31585 17.2908 8.25 17.125 8.25C16.7935 8.25 16.4755 8.1183 16.2411 7.88388C16.0067 7.64946 15.875 7.33152 15.875 7C15.875 6.66848 16.0067 6.35054 16.2411 6.11612C16.4755 5.8817 16.7935 5.75 17.125 5.75ZM16.5 9.41875V12H12.125V10.125H10.875V12H1.5V9.41875C2.035 9.27892 2.50854 8.96566 2.84651 8.528C3.18449 8.09034 3.36782 7.55297 3.36782 7C3.36782 6.44703 3.18449 5.90966 2.84651 5.472C2.50854 5.03434 2.035 4.72108 1.5 4.58125V2H10.875V3.875H12.125V2H16.5V4.58125C15.965 4.72108 15.4915 5.03434 15.1535 5.472C14.8155 5.90966 14.6322 6.44703 14.6322 7C14.6322 7.55297 14.8155 8.09034 15.1535 8.528C15.4915 8.96566 15.965 9.27892 16.5 9.41875Z",fill:"#1F5E72"}));function nn(){const{event:t}=c.useContext(R),s=t==null?void 0:t.tickets.filter(i=>i.name),r=t==null?void 0:t.packages.filter(i=>i.name);return e.jsxs("div",{className:"event-ticket-tile",children:[e.jsxs("div",{className:"eventee d-flex flex-row ",children:[" ",e.jsxs("p",{children:["Ticket Type:"," ",e.jsx("span",{className:"eventtickettypetext",children:t.eventTicketType.label})]}),e.jsxs("p",{className:"green",children:[" ",`Sold: ${t.soldTickets||0} / ${t.totalTickets}`]})]}),s.length>0&&e.jsxs("div",{className:"d-flex justify-content-between flex-column",children:[e.jsx("div",{className:"heading",children:e.jsx(se,{type:"h3",children:"Single Tickets"})}),e.jsx("div",{className:"d-flex",children:s.map((i,m)=>e.jsxs("div",{className:"mb-4 mr-4",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 mt-1",children:[" ",e.jsx("div",{className:"mr-3",children:e.jsx(mt,{})}),e.jsx("div",{className:"headingss",children:e.jsx("div",{type:"h4",children:i.name||"N/A"})}),t.eventTicketType.value&&e.jsx("span",{className:"title pl-2",children:e.jsx("div",{className:"tickets",children:`Sold: ${i.soldTickets||0} / ${i.totalTickets}`})}),i.hidden&&e.jsx("span",{className:"ml-4 hidden",children:"(hidden)"})]}),e.jsxs("div",{className:"d-flex custom-flex mt-1 ",children:[e.jsx("div",{className:"title mr-2",children:t.eventTicketType.value==="payWhatYouCan"?"Recommended price:":"Price per ticket:"}),e.jsxs("div",{className:"description",children:["$",t.eventTicketType.value==="payWhatYouCan"?Me(me(i.price||"0")):Me(me(i.price))||"N/A"]})]}),e.jsxs("div",{className:"d-flex custom-flex",children:[e.jsx("div",{className:"title mr-2",children:"Total number of tickets:"}),e.jsx("div",{className:"description",children:i.totalTickets||"N/A"})]}),e.jsxs("div",{className:"d-flex custom-flex",children:[e.jsx("div",{className:"title mr-2",children:"Max no. of tickets allowed per order:"}),e.jsx("div",{className:"max-order",children:i.maxOrder||"N/A"})]})]},m))})]}),r.length>0&&e.jsxs("div",{className:"d-flex justify-content-between flex-column",children:[e.jsx(se,{type:"h3",children:"Group Tickets"}),e.jsx("div",{className:"d-flex",style:{flexWrap:"wrap"},children:r.map((i,m)=>e.jsxs("div",{className:"mb-4 mr-4",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 mt-1 mb-1",children:[" ",e.jsx("div",{className:"mr-3",children:e.jsx(mt,{})}),e.jsxs("div",{className:"headingss",children:[" ",e.jsx("div",{children:i.name})," "]}),t.eventTicketType.value&&e.jsx("span",{className:"title pl-2",children:e.jsx("div",{className:"tickets",children:`Sold: ${i.numOfTickets*i.soldPackage||0} / ${i.numOfTickets*i.numOfGroupsAvailable}`})}),i.hidden&&e.jsx("span",{className:"ml-4 hidden",children:"(hidden)"})]}),e.jsxs("div",{className:"d-flex custom-flex",children:[e.jsxs("div",{className:"title mr-2 ",children:[" ",t.eventTicketType.value==="payWhatYouCan"?"Recommended price:":"Price per ticket:"]}),e.jsxs("div",{className:"description",children:["$",t.eventTicketType.value==="payWhatYouCan"?i.price||"0":i.price||"N/A"]})]}),e.jsxs("div",{className:"d-flex custom-flex",children:[e.jsx("div",{className:"title mr-2",children:"No of groups available: "}),e.jsx("div",{className:"description",children:i.numOfGroupsAvailable||"N/A"})]}),e.jsxs("div",{className:"d-flex custom-flex",children:[e.jsx("div",{className:"title mr-2",children:"Total number of tickets:"}),e.jsx("div",{className:"description",children:i.numOfTickets||"N/A"})]}),e.jsxs("div",{className:"d-flex custom-flex",children:[e.jsx("div",{className:"title mr-2",children:"Max no. of groups allowed per order:"}),e.jsx("div",{className:"description",children:i.maxOrderPackage||"N/A"})]})]},m))})]})]})}function rn({id:t,redeemCount:s,discountRedeem:r,couponName:i,status:m,discountPercentage:a}){return e.jsxs("div",{className:"event-coupon-view",children:[e.jsxs("div",{className:"coupon-redeem-section",children:[e.jsxs(se,{type:"h3",children:["Coupon ",t]}),e.jsxs("span",{class:"coupon-redeem",children:["Coupon Redeemed: ",s," "]}),e.jsxs("span",{class:"discount-redeem",children:["Total Discount Redeemed: $",r?r.toFixed(2):"0.00"]})]}),e.jsxs("div",{className:"coupon-info",children:[e.jsxs("div",{className:"coupon-detail-labels",children:[e.jsx("div",{className:"inner
8-detail-section",children:e.jsx("span",{className:"label",children:"Coupon name:"})}),e.jsx("div",{className:"inner-detail-section",children:e.jsx("span",{className:"label",children:"Status:"})}),e.jsx("div",{className:"inner-detail-section",children:e.jsx("span",{className:"label",children:"Discount percentage:"})})]}),e.jsxs("div",{className:"coupon-detail-values",children:[e.jsx("div",{className:"inner-detail-section",children:e.jsx("span",{className:"value",children:i})}),e.jsx("div",{className:"inner-detail-section",children:e.jsx("span",{className:"value",children:m})}),e.jsx("div",{className:"inner-detail-section",children:e.jsxs("span",{className:"value",children:[a,"% "]})})]})]})]})}const on=({data:t,onClick:s,disabled:r})=>{var b,g,f,l,v;const{activeForm:i,validationState:m,event:a}=c.useContext(R),{title:n,values:o,id:d}=t,u=is(d,m),x=(h=>Array.isArray(h)?h:Object.values(h))(a.eventContextImages),N=(h,C,T,y,E)=>{const A=V=>{let Z;if(V instanceof Date)Z=V;else if(typeof V=="string")Z=new Date(`${V}T00:00:00`);else return"Invalid Date";Z.setHours(10,0,0,0);const W=Z.getFullYear(),ae=String(Z.getMonth()+1).padStart(2,"0"),ee=String(Z.getDate()).padStart(2,"0");return`${W}/${ae}/${ee}`},I=A(h),z=A(T);let M;return E.dateToBeAnnounced?M="To be announced":E.multiDayEvent?M=`${I} to ${z} `:E.oneDayEvent&&(M=`${I} `),M},j=h=>{let C;if(h.dateToBeAnnounced)C="To be announced";else{const T=h.startTime,y=h.endTime;h.multiDayEvent?C=y?`${T} to ${y} `:`${T} `:h.oneDayEvent&&(C=y?`${T} to ${y} `:`${T}`)}return C};return e.jsx("div",{disabled:r,onClick:s,className:`event-tiles-component ${((b=m.find(h=>h.id===d))==null?void 0:b.isValid)===!1?"error-border":""}`,children:e.jsxs("div",{children:[e.jsxs("div",{className:"heading",children:[e.jsx("div",{className:`step ${i===d?"active":""} ${u?"completed":""} `,children:d}),e.jsxs("div",{className:"d-flex align-items-center",children:[e.jsx(se,{type:"h3",children:n}),((g=m.find(h=>h.id===d))==null?void 0:g.isValid)===!1&&d!==7?e.jsx("div",{className:"ml-3 mb-1",children:e.jsx(Be,{})}):null]}),t.optional&&e.jsx("span",{className:"optional",children:"(Optional)"})]}),e.jsxs("div",{className:"event-tile-body",children:[o&&(Object.values(o).some(h=>h)?Object.keys(o).map((h,C)=>e.jsx("div",{style:{wordBreak:"break-word"},children:o[h]&&e.jsxs("div",{className:"body",children:[e.jsxs("span",{className:"title",children:[rs(h),":"," "]}),e.jsx("span",{className:"description",children:o[h]||"None"})]},C)},C)):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"body"}),a.cover&&d===6&&e.jsx("div",{className:"event-cover-section",children:e.jsx(je,{square:!0,datatest:"event-logo",id:"cover",width:"100%",file:a.cover})}),x.length>0&&d===7&&e.jsx("div",{className:"d-flex justify-content-center context-image-area",children:e.jsx(Dt,{ViewOnly:!0,gallery:!0,count:x.length,images:x})}),d===5&&e.jsx("div",{className:"coupon-view-tile",children:(a.coupons||[]).length>0?[...a.coupons].sort((h,C)=>(h.index||0)-(C.index||0)).map((h,C)=>{var T;return e.jsx(rn,{id:C+1,redeemCount:h.redeemCount||0,discountRedeem:h.discountRedeem||0,couponName:h.name||"Unknown",status:((T=h.status)==null?void 0:T.label)||"-",discountPercentage:h.discountPercentage||0},C)}):((f=a.eventTicketType)==null?void 0:f.value)==="free"||((l=a.eventTicketType)==null?void 0:l.value)==="payWhatYouCan"?e.jsx("p",{className:"content",children:"Coupons cannot be created for Free and Pay what you can event."}):e.jsx("p",{className:"content",children:"No coupons created."})}),Object.values(a.pointOfContact).some(h=>h)&&d===8&&e.jsxs("div",{className:"pointofnoc d-flex justify-content-between ",children:[e.jsxs("div",{className:"body d-flex flex-column justify-content-center",children:[e.jsxs("span",{className:"titles",children:[e.jsx("span",{className:"title",children:"Name:"}),e.jsx("span",{className:"description",children:a.pointOfContact.name||"N/A"})]}),e.jsxs("span",{className:"titles",children:[e.jsx("span",{className:"title",children:"Email: "}),e.jsx("span",{className:"description",children:a.pointOfContact.email||"N/A"})]}),e.jsxs("span",{className:"titles",children:[e.jsx("span",{className:"title",children:"Role: "}),e.jsx("span",{className:"description",children:a.pointOfContact.role||"N/A"})]}),e.jsxs("span",{className:"titles ",children:[e.jsx("span",{className:"title ",children:"Mobile phone: "}),e.jsx("span",{className:"description",children:a.pointOfContact.businessPhone||"N/A"})]})]}
8),e.jsx("div",{children:e.jsx(je,{datatest:"event-logo",id:"cover",width:"150px",file:a.pointOfContact.image})})]}),Object.values(a.pointOfContact).some(h=>h)&&d===2&&e.jsx("div",{className:"calendardate",children:e.jsx("div",{className:"ss ",children:e.jsxs("div",{className:"body d-flex flex-row ",children:[e.jsx("span",{className:"title",children:e.jsx("span",{className:"description",children:e.jsx(Ae,{icon:e.jsx(ra,{}),heading:"Impact Site",value:a.eventTypeOnsite?a.location:a.eventTypeOnline?"Online":a.eventOnlineToBeAnnounced?"To be announced":""})})}),e.jsx("span",{className:"title",children:e.jsx("span",{className:"description",children:e.jsx(Ae,{icon:e.jsx(dt,{}),heading:"Event Date",value:N(a.startDate,a.startTime,a.endDate,a.endTime,a)})})}),e.jsx("span",{className:"title",children:e.jsx("span",{className:"description",children:e.jsx(Ae,{icon:e.jsx(dt,{}),heading:"Event Time",value:j(a)})})}),e.jsx("span",{className:"title",children:e.jsx("span",{className:"description",children:e.jsx(Ae,{icon:e.jsx(Us,{className:"invert"}),heading:"Timezone ",value:((v=a.timezone)==null?void 0:v.label)||"N/A"})})})]})})})]})),d===4&&e.jsx(nn,{}),a.fundRaisingContent&&d===9&&e.jsx("div",{className:"fundraising-content",children:a.fundRaisingContent.length>0&&a.fundRaisingContent.map((h,C)=>e.jsxs("div",{className:"fundraising-item",children:[e.jsxs("strong",{className:"posted-at",children:["Posted at: ",new Date(h.postedAt).toLocaleString()]}),e.jsx("p",{className:"content",children:h.content})]},C))})]})]})})},cn=({title:t,description:s,id:r,activeForm:i,optional:m})=>{var o;const{validationState:a}=c.useContext(R),n=(o=a.find(d=>d.id===r))==null?void 0:o.isValid;return e.jsxs("div",{className:"event-header-tiles-component",children:[e.jsxs("div",{className:"heading mt-4",children:[e.jsx("div",{className:`step ${i===r?"active":""}`,children:r}),e.jsxs("div",{className:"d-flex align-items-center ",children:[e.jsx(se,{type:"h3",children:t}),n===!1&&r!==6&&r!==7&&r!==8&&e.jsx("div",{className:"ml-3 mb-1",children:e.jsx(Be,{})})]}),m&&e.jsx("span",{className:"optional",children:"(Optional)"})]}),e.jsx("div",{className:"body pr-3 pt-3 pb-3",children:e.jsx("span",{className:"title",children:s})})]})},ln=({canEdit:t,view:s,ignoreBlocking:r})=>{const{eventErrors:i,setEventErrors:m,eventEdit:a,setEvent:n,event:o,activeForm:d,setActiveForm:u,setValidationState:p,validationState:x,eventPage:N}=c.useContext(R),j=Hs(o),[b,g]=c.useState(!1);c.useEffect(()=>{const l=x.map(v=>v.id===d?{...v,isOpen:!v.isOpen}:v);p(l)},[d]);const f=l=>{const v=x.map(h=>h.id===d?{...h,isOpen:!h.isOpen}:h);p(v),u(l)};return e.jsxs("div",{className:"event-template-component",children:[j&&j.map(l
8=>{const v=l.id===5&&(o.eventTicketType.value==="free"||o.eventTicketType.value==="payWhatYouCan");return l.id===d?K.cloneElement(l.component,{key:l.id,id:l.id,initialValues:l.initialValues,value:l.values,canEdit:t,event:o,eventErrors:i,setEvent:n,setEventErrors:m,setOverlay:g,view:"admin",headerContent:e.jsx(cn,{title:l.title,description:l.description,optional:l.optional,id:l.id,activeForm:d}),disabled:v}):e.jsx(on,{value:l.values,data:l,disabled:v,onClick:()=>!v&&f(l.id)},l.id)}),t&&b&&e.jsx(ia,{})]})},dn=()=>{const t=ve(),s=Te(),[r,i]=c.useState([]),m=async a=>{try{const{filePath:n}=St(a);le.auth().currentUser.getIdToken(!0).then(p=>{}).catch(p=>{console.error("Error refreshing token:",p)});const u=await le.storage().ref(n).getDownloadURL();window.open(u,"_blank")}catch(n){console.error("Error fetching download URL:",n)}};return K.useEffect(()=>{i([{Header:"Users",columns:[{Header:"Email",accessor:"Email",Cell:n=>n.value?e.jsx("span",{style:{textDecoration:"underline",cursor:"pointer"},onClick:()=>t(`/donor-lookup/${n.row.original.id}/transaction-history`),children:n.value}):e.jsx("span",{}),export:n=>n.Email||"-"},{Header:"Name",accessor:"Name",Cell:n=>n.value?e.jsx("span",{style:{display:"block",textDecoration:"underline",cursor:"pointer",width:"224px"},onClick:()=>t(`/donor-lookup/${n.row.original.id}/transaction-history`),children:n.value}):e.jsx("span",{}),export:n=>n.Name||"-"},{Header:"Status",accessor:"Status",Cell:n=>e.jsx(os,{children:n.value}),export:n=>n.Status||"-"},{Header:"Purchased On",accessor:"Purchased On",export:n=>n["Purchased On"]||"-"},{Header:"Discount",accessor:"discountedAmount",export:n=>n.discountedAmount||"-"},{Header:"Coupon Code",accessor:"couponCode",export:n=>n.couponCode||"-"},{Header:"Tickets Purchased",accessor:"Tickets Purchased",export:n=>n["Tickets Purchased"]||"-"},{Header:"Ticket name",accessor:"Normal",Cell:({row:n})=>{const o=n.original.Normal||[],d=n.original.Package||[],u=o.map(N=>`${N.Details.quantity} x ${N.Details.name}`),p=d.map(N=>`${N.Details.countofGroup} x ${N.Details.name}(${N.Details.numOfTickets})`),x=[...u,...p].filter(Boolean);return e.jsx("div",{children:x.map((N,j)=>e.jsx("p",{children:N},j))})},export:n=>{const o=n.Normal||[],d=n.Package||[],u=o.map(x=>`${x.Details.quantity} x ${x.Details.name}`),p=d.map(x=>`${x.Details.countofGroup} x ${x.Details.name}(${x.Details.numOfTickets})`);return[...u,...p].join(", ")||"-"}},{Header:"Tickets scanned",accessor:"Tickets scanned",Cell:({row:n,value:o})=>{const[d,u]=c.useState(o),p=async()=>{const N={docId:n.original.eventProcceedRefId,totalSingleScan:parseInt(d,10)};try{await le.functions().httpsCallable("adminFunctions-updateTotalSingleScan")(N)}catch(j){console.error("Error updating Tickets scanned",j)}},x=N=>{let j=N.target.value===""?"":parseInt(N.target.value,10);const b=parseInt(n.original["Tickets Purchased"],10);!isNaN(j)&&j>=0&&(j<=b||N.target.value==="")?u(j):j<0&&u(0)};return e.jsx("input",{type:"number",value:d,onChange:x,onBlur:p,style:{width:"50%"}})},export:n=>n["Tickets scanned"]||"-"},{Header:"Donated Amount",accessor:"Amount",Cell:n=>e.jsx("span",{children:me(n.value).toFixed(2)}),export:n=>n.Amount!==void 0?me(n.Amount).toFixed(2):"-"},{Header:"Total Contribution",accessor:"Total",Cell:n=>e.jsx("span",{children:me(n.value).toFixed(2)}),export:n=>n.Total!==void 0?me(n.Total).toFixed(2):"-"},{Header:"Last scanned on",accessor:"Last scanned on",export:n=>n["Last scanned on"]||"-"},{Header:"Ticket Type",accessor:"Ticket Type",export:n=>n["Ticket Type"]||"-"},{Header:"Donor covered service fee",accessor:"Service Charges",Cell:n=>e.jsx("span",{children:me(n.value).toFixed(2)}),export:n=>n["Service Charges"]!==void 0?me(n["Service Charges"]).toFixed(2):"-"},{Header:"Generated By Admin",accessor:"Generated By Admin",Cell:n=>n.data[n.row.index]["Generated By Admin"]?e.jsx(Pt,{width:"15px",height:"15px"}):e.jsx("span",{children:"-"}),export:n=>n["Generated By Admin"]?"Yes":"No"},{Header:"Admin Email",accessor:"Admin Email",export:n=>n["Admin Email"]||"-"},{Header:"Order Id",accessor:"eventProcceedRefId",export:n=>n.eventProcceedRefId||"-"},{Header:"Guest List",showActionButton:!0,Cell:n=>{const o=n.row.index;n.data[o].orderId;const d=n.data[o].eventProcceedRefId,u=n.data[o].guestList,p=n.data[o].eventId;return u.length>0?e.jsx(Ve,{primaryShade:!0,handleClick:()=>{s({type:"SET_OPEN_GUEST_MODAL",payload:{open:!0,data:u,eventId:p,eventProcceedRefId:d,id:n.data[o].id}})},children:"View"}):e.jsx(Ve,{primaryShade:!0,handleClick:()=>{s({type:"SET_OPEN_GUEST_MODAL",payload:{open:!0,data:u,eventId:p,eventProcceedRefId:d}})},children:"Add Guest"})}},{Header:"Download Ticket",showActionButton:!0,Cell:n=>{const{pdf:o}=n.data[n.row.index];return e.jsx(Ve,{primaryShade:!0,handleClick:()=>m(o),children:"Download"})},export:n=>n.pdf||"No PDF"}]}])},[history]),r},mn=t=>Object.keys(t).reduce((s,r)=>{const i=r.split("-")[1];return s[i]=t[r],s},{});function un(t,s){const r=s.reduce((i,m)=>(i[m.id.toString()]=m,i),{});return Object.keys(t).map(i=>{const m=r[i],a=t[i].quantity;return{Details:{name:m?m.name:"Not Found",quantity:a}}})}function hn(t,s){const r=s.reduce((i,m)=>(i[m.id.toString()]=m,i),{});return Object.keys(t).map(i=>{const m=r[`pack-${i}`],a=t[i].quantity,n=m&&m.numOfTickets?a/m.numOfTickets:"numOfTickets not available";return{Details:{name:m?m.name:"Not Found",quantity:a,countofGroup:n,numOfTickets:m?m.numOfTickets:"Not Found"}}})}async function pn(t){const s=Tt.collection("users"),r={},i=t.map(a=>s.doc(a).get());
8return(await Promise.all(i)).forEach(a=>{a.exists?r[a.id]=a.data():r[a.id]=null}),r}function xn(t){const s=[];return Object.entries(t).forEach(([r,i])=>{i.forEach(m=>{const a={...m,Status:m.Status};s.push(a)})}),s}async function vn(t){const s=Object.keys(t),r=await pn(s);return s.forEach(i=>{const m=r[i];m?t[i].forEach(a=>{a.id=i,a.Name=m.displayName,a.Email=m.email,a.Status=ca(m)}):t[i].forEach(a=>{a.Status="Error"})}),xn(t)}const fn=(t,s,r,i)=>{const a=Tt.collection("EventTicketsProceeds").where("EventId","==",t).orderBy("TimeValue","desc");i(!0);const n=a.onSnapshot(o=>{if(o.empty){r([]),i(!1);return}const d={};o.docs.forEach(u=>{const p=u.data(),x=u.id;if(!s||!s.tickets){i(!1);return}p.packageTicketsByIds=p.packageTicketsByIds?mn(p.packageTicketsByIds):{};const N=new Date(p.TimeValue.seconds*1e3),j=[N.getFullYear(),(N.getMonth()+1).toString().padStart(2,"0"),N.getDate().toString().padStart(2,"0")].join("/"),b={orderId:p.donationId,guestList:p.guestList?p.guestList:[],Total:p.Total,discountedAmount:p.discountedAmount,couponCode:p.couponCode,eventProcceedRefId:x,"Service Charges":p.Tip,"Purchased On":j,"Tickets scanned":p.totalSingleScan||0,"Ticket Type":s.eventTicketType.label,"Last scanned on":cs(p.lastScannedTime)||"",pdf:p.Pdf?p.Pdf:"-","Admin Email":p.adminEmail||"-","Generated By Admin":!!p.isGeneratedByAdmin,Normal:un(p.normalTicketByIds,s.tickets),Package:hn(p.packageTicketsByIds,s.packages),Amount:p.reverse?0:p.Amount,"Tickets Purchased":p.TotalTickets};d[p.UID]||(d[p.UID]=[]),d[p.UID].push(b)}),vn(d).then(u=>{r(u),i(!1)}).catch(u=>{console.error("Error processing ticket details: ",u),i(!1)})},o=>{console.error("Error fetching event participants data: ",o),i(!1)});return ls.add(`event-attendees-${t}`,n,!0),n},gn=t=>c.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("path",{d:"M13.3334 4L6.00002 11.3333L2.66669 8",stroke:"#E68F08",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})),jn=t=>c.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("path",{d:"M11.3334 4.66669L4.66669 11.3334M4.66669 4.66669L11.3334 11.3334",stroke:"#98A2B3",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})),ut={"& .MuiOutlinedInput-root":{borderRadius:3,"&.Mui-focused fieldset":{borderColor:"var(--primary-color)"}}},bn=({setValue:t,setError:s,error:r,required:i,value:m,disabled:a,setCountryCode:n,countryCode:o})=>{var f;const d=c.useRef(),[u,p]=c.useState(!1),[x,N]=c.useState(""),j=()=>p(!u),b=l=>{n({label:re[l].label,value:l}),p(!1),N("")};c.useEffect(()=>{const l=v=>{d.current&&!d.current.contains(v.target)&&p(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]);const g=Object.keys(re).filter(l=>re[l].name.toLowerCase().includes(x.toLowerCase())||re[l].label.includes(x));return e.jsxs("div",{className:"contact-field-atom",children:[o&&e.jsxs("div",{className:"selected country-container",onClick:j,disabled:a,children:[e.jsxs("div",{className:"country-details",children:[e.jsx("div",{className:"country-icon",children:((f=re[o.value])==null?void 0:f.icon)&&K.createElement(re[o.value].icon)}),e.jsx("div",{className:"country-code",children:o.label})]}),e.jsx(pa,{})]}),u&&e.jsxs("div",{className:"countries-dropdown",ref:d,children:[e.jsx("div",{className:"search-container",children:e.jsx("input",{type:"text",className:"country-search",placeholder:"Search country or code...",value:x,onChange:l=>N(l.target.value)})}),e.jsx("div",{className:"country-list",children:g.length>0?g.map((l,v)=>{var h;return e.jsxs("div",{className:"country-container",onClick:()=>b(l),children:[e.jsx("div",{className:"country-icon",children:((h=re[l])==null?void 0:h.icon)&&K.createElement(re[l].icon)}),e.jsx("div",{className:"country-code",children:re[l].label}),e.jsx("div",{className:"country-name",children:re[l].name})]},v)}):e.jsx("div",{className:"no-results",children:"No results found"})})]}),e.jsx(It,{type:"text",setError:s,error:r,required:i,value:m,label:"Phone Number",disabled:a,setValue:l=>t(l),white:!0})]})},Nn=({guestList:t,event:s,eventProcceedRefId:r,id:i,ticketsPurchased:m})=>{const a=Te(),[n,o]=c.useState(null),[d,u]=c.useState(t.map(f=>({...f,phone:f.phone||"",countryCode:f.countryCode||{label:"+1",value:"ca"}}))),{handleManageGuestList:p}=ha(),x=()=>{a({type:"SET_OPEN_GUEST_MODAL",payload:{open:!1,data:[],eventId:null,eventProcceedRefId:null,id:null}})},N=(f,l,v)=>{const h=[...d];h[f]={...h[f],[l]:v},u(h)},j=async f=>{let l=[...d];l.splice(f,1),u(l);const v={eventId:s.id,guestList:l,eventProcceedRefId:r,token:null,id:i,isAdmin:!0};(await p(v)).success?Q.success("Deleted successfully"):Q.error("Failed to delete"),l.length===0&&x()},b=async()=>{o(null);const f=d.filter(h=>h.email&&h.name),l={eventId:s.id,guestList:f,eventProcceedRefId:r,token:null,id:i,isAdmin:!0},v=await p(l);v.success?Q.success(v.message):Q.error(v.message)},g=async()=>
8{const f={name:"",email:"",phone:"",countryCode:{label:"+1",value:"ca"}},l=[...d,f];u(l),o(l.length-1);const v={eventId:s.id,guestList:l,eventProcceedRefId:r,token:null,id:i};(await p(v)).success?u(l):Q.error("Failed to add guest")};return e.jsx("div",{children:e.jsxs(ds,{onClose:x,open:!0,fullWidth:!0,sx:{"& .MuiDialog-container":{"& .MuiPaper-root":{width:"100%",maxWidth:"1050px",height:"550px"}}},children:[e.jsx(ms,{onClose:x,children:e.jsx(us,{children:"Guest list"})}),e.jsxs(Mt,{children:[e.jsx(Rt,{sx:{...hs,mt:4},children:e.jsxs(Bt,{children:[e.jsx(Ut,{children:e.jsxs(et,{children:[e.jsx(oe,{width:"30%",className:"header-cell",children:"Email"}),e.jsx(oe,{width:"20%",className:"header-cell",children:"Name"}),e.jsx(oe,{width:"40%",className:"header-cell",children:"Phone-No"}),e.jsx(oe,{width:"5%",className:"header-cell",children:"Ticket id"}),e.jsx(oe,{width:"5%",className:"header-cell",children:"Action"})]})}),e.jsx(Ht,{children:d.map((f,l)=>{var v;return e.jsxs(et,{children:[e.jsx(oe,{sx:{maxWidth:250},children:n===l?e.jsx(We,{value:f.email,onChange:h=>N(l,"email",h.target.value),fullWidth:!0,sx:ut}):e.jsx("div",{className:"container",children:f.email?f.email:"-"})}),e.jsx(oe,{sx:{maxWidth:200},children:n===l?e.jsx(We,{value:f.name,onChange:h=>N(l,"name",h.target.value),fullWidth:!0,sx:ut}):e.jsx("div",{className:"container",children:f.name?f.name:"-"})}),e.jsx(oe,{sx:{maxWidth:200},children:n===l?e.jsx(bn,{countryCode:f.countryCode,setCountryCode:h=>N(l,"countryCode",h),value:f.phone,setValue:h=>N(l,"phone",h)}):e.jsx("div",{className:"container",children:f.phone||"-"})}),e.jsx(oe,{children:l+1}),e.jsx(oe,{children:n===l?e.jsxs(Oe,{direction:"row",aligItems:"center",children:[" ",e.jsx(Pe,{size:"small",onClick:()=>{u([...t]),o(null)},sx:{ml:1},children:e.jsx(jn,{fontSize:"small"})}),e.jsx(Pe,{size:"small",onClick:()=>b(),disabled:!((v=f.email)!=null&&v.trim()),sx:{ml:1},children:e.jsx(gn,{fontSize:"small"})})]}):e.jsx(Oe,{direction:"row",aligItems:"center",children:e.jsx(Pe,{size:"small",onClick:()=>j(l),sx:{ml:1},children:e.jsx(ua,{fontSize:"small"})})})})]},l)})})]})}),d.length<m&&e.jsx("div",{style:{marginTop:"20px",textAlign:"center"},children:e.jsx(ps,{variant:"primary",onClick:g,children:"Add Guest"})})]})]})})},ht=()=>{const{event:t}=c.useContext(R),[s,r]=c.useState(!1),[i,m]=c.useState([]),a=He(t.id),n=Te(),o=dn(),d=xs(new Date,"yyyy-MM-dd"),{viewGuestList:u}=X(x=>x.events);K.useEffect(()=>{t.id&&fn(t.id,a,m,r)},[n,t.id,a]);const p=async()=>{try{r(!0),da({type:"event-prticipants",data:i,fileName:`${t.eventName}_Event_attendees_${d}.xlsx`})}catch(x){Q.error(x.message)}finally{r(!1)}};return e.jsxs("div",{className:"event-transactions-details",children:[e.jsxs("div",{className:"transactions-details",children:[e.jsx("div",{className:"utils",children:e.jsxs(ce,{loading:s,disabled:s||!i.length,utility:!0,handleClick:p,children:["Export",e.jsx(la,{className:"icon"})]})}),o&&e.jsx(oa,{columns:o,keyvalues:["Name"],totalSize:i.length,data:i,loading:s})]}),u.open&&e.jsx(Nn,{guestList:u.data?u.data:[],event:t,eventProcceedRefId:u==null?void 0:u.eventProcceedRefId,id:u==null?void 0:u.id,ticketsPurchased:i&&Array.isArray(i)&&i.length>0?i.filter(x=>x.eventProcceedRefId===(u==null?void 0:u.eventProcceedRefId)).reduce((x,N)=>x+(N["Tickets Purchased"]||0),0):0})]})},Cn=()=>e.jsxs("div",{className:"ellipsis-container",children:[e.jsx("div",{className:"ellipsis-circle"}),e.jsx("div",{className:"ellipsis-circle"}),e.jsx("div",{className:"ellipsis-circle"})]}),yn=({event:t})=>{var y;const{currentUser:s}=X(E=>E.user),{userTickets:r}=X(E=>E.events),[i,m]=c.useState(0),[a,n]=c.useState(!1),[o,d]=c.useState(!0),[u,p]=c.useState(""),[x,N]=K.useState(!1),[j,b]=c.useState(t.soldTickets),[g,f]=c.useState({label:"",value:""}),l=Te(),v=()=>{if(g)return[{quantity:i,price:0,name:g.label,taxPercentAmount:0,taxPercentage:0,ticketType:g.ticketType.value||g.ticketType,package:!1,id:g.value}]},h=()=>{if(!o)d(!0),p(""),m(0),f({label:"",value:""});else if(i>parseInt(t.totalTickets)-(t.soldTickets?t.soldTickets:0))st.fire({icon:"warning",title:"Tickets count has exceeded",text:"If you want to generate tickets please increase total tickets count",confirmButtonColor:"var(--primary-color)"});else if(u&&g&&g.value>=0&&i>0){n(!0);const E={amount:0,eventId:t.id,noOfTickets:i,tickets:v(),packages:[],packagesSelected:!1,taxPercentage:0,tip:0,total:0,email:u||s.email,adminAuth:!!u,adminEmail
8:s.email,isAdmin:!0};b(t.soldTickets?t.soldTickets:0),l(fs(E,!0))}else st.fire({icon:"warning",title:"Values are not selcted",text:"If you want to generate tickets please select all relevant fields",confirmButtonColor:"var(--primary-color)"})};c.useEffect(()=>{t.soldTickets!==j&&(n(!1),d(!1))},[t,j]);const C=E=>{if(E==="add"){const A=t.tickets.filter(I=>I.name===g.label)[0];if(A){if(i<t.totalTickets-t.soldTickets&&i<A.totalTickets-((A==null?void 0:A.soldTickets)||0)){let I=i;I=I+1,m(I)}else if(A){const I=A.soldTickets||0;I>0?Q.warning(`Tickets limit has been reached. ${I} ticket(s) have already been sold`):Q.warning("Tickets limit has been reached. No ticket(s) has been sold out so far")}}else Q.warning("Please select a ticket type")}else{let A=i;A>0&&(A=A-1,m(A))}},T=async()=>{const E=r.sort((A,I)=>new Date(I.TimeValue.seconds*1e3+I.TimeValue.nanoseconds/1e6)-new Date(A.TimeValue.seconds*1e3+A.TimeValue.nanoseconds/1e6))[0];try{const{filePath:A}=St(E.Pdf);le.auth().currentUser.getIdToken(!0).then(V=>{}).catch(V=>{console.error("Error refreshing token:",V)});const M=await le.storage().ref(A).getDownloadURL();window.open(M,"_blank")}catch(A){console.error("Error fetching download URL:",A)}};return e.jsxs("div",{className:"generate-free-tickets-admin",children:[e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"heading-message",children:[e.jsx("span",{className:"desc",children:"Generate No. of Free Tickets"}),e.jsxs("div",{className:"total-ticket-footer",children:[(t.eventOnlineToBeAnnounced||t.dateToBeAnnounced)&&e.jsx("span",{className:"note-msg",children:"Tickets will go on sale once the event's date, time, or location is confirmed"}),e.jsx("br",{}),e.jsxs("span",{children:["Total Tickets Generated:"," ",t.freeTicketsByAdmin?t.freeTicketsByAdmin:0]})]})]}),o&&e.jsx(xa,{ticketCount:i,addRemoveFunction:C})]}),o&&e.jsx("div",{className:"event-ticket-select",children:e.jsx(vs,{"data-test":"ticket-dropdown",option:g,white:!0,setOption:f,options:t.tickets.map(E=>({label:E.name,value:E.id,ticketType:E.ticketType})),defaultLabel:"Select Ticket",placeholder:"Select Ticket"})}),o&&e.jsxs("div",{className:"email-generate-btn",children:[e.jsx(It,{value:u,setValue:p,regularExpression:tt,type:"email",name:"email",setError:N,"data-test":"email",error:x,label:"Email *",placeholder:"Email of recipient",errorMessage:"Email you entered is in incorrect format"}),e.jsx(ce,{disabled:t.dateToBeAnnounced||t.eventOnlineToBeAnnounced,handleClick:h,loading:a,disbaledColor:a,component:a?e.jsx(Cn,{}):"",gray:!!(!a&&o&&!(u.match(tt)&&i>0&&g&&g.value>=0&&g.value!=="")),children:a?"Generating":"Generate Tickets"})]}),!o&&e.jsxs("div",{className:"footer",children:[e.jsxs("div",{className:"msg",children:[e.jsx(Pt,{className:"tick-icon"}
8),e.jsxs("span",{children:[i," ",((y=g.ticketType)==null?void 0:y.label)||""," Tickets Generated"]})]}),e.jsx("div",{className:"more",children:e.jsx(ce,{handleClick:T,primaryShade:!0,disbaledColor:a,component:e.jsx(va,{className:"arrowDown"}),children:"Download Tickets"})}),e.jsx("div",{onClick:h,className:"down",children:e.jsx("span",{className:"download",children:"Generate More Tickets"})})]}),e.jsx("div",{className:"note-msg",children:e.jsx("span",{children:"Find free generated tickets in Event Attendees tab"})})]})},kn=({eventEdit:t})=>{const{event:s,setEvent:r}=c.useContext(R),i=fe("currencySymbol"),[m,a]=c.useState([]),[n,o]=c.useState(!1),[d,u]=c.useState(!0);return c.useEffect(()=>{if(s&&s.eventId){const p=sa(s);a(p.eventFigures),o(s.hideProgressBar??!1),u(!1)}},[s]),e.jsx("div",{className:"admin-event-page-stats-component",children:e.jsx("div",{className:"event-figure-container",children:d?e.jsx("div",{className:"loading-container",children:e.jsx(Et,{height:130,children:e.jsx(wt,{})})}):e.jsxs(e.Fragment,{children:[m.map((p,x)=>e.jsxs("div",{"data-test":`event-${p.label}`,className:"user-figure",children:[e.jsxs("div",{"data-test":`event-${p.label}-number`,className:"amount",children:[p.amount&&i,p.amount?p.amount:p.count]}),e.jsxs("div",{className:"label",children:[p.label," "]})]},x)),e.jsxs("div",{"data-test":"event-share",className:"user-figure",children:[e.jsx("div",{"data-test":"event-share-number",className:"amount",children:s.eventTicketType.label}),e.jsx("div",{className:"label",children:"Event Type"})]}),e.jsx("div",{className:"user-figure",children:e.jsx(fa,{event:s,info:"Ticketing Information"})})]})})})},pt=window.location.origin,Sn=({})=>{const[t,s]=c.useState(""),[r,i]=c.useState(""),[m,a]=c.useState(""),[n,o]=c.useState(!1),[d,u]=c.useState(!1),[p,x]=c.useState(!1),[N,j]=c.useState(!1),{event:b,setEvent:g}=c.useContext(R);c.useEffect(()=>{if(b&&b.eventId){o(b.hideProgressBar??!1),u(b.hideaccountblock??!1);const C=b.hidefeed??b.hideFeed??!1;x(!!C),j(b.hideDonateOption??!1)}},[b]),c.useEffect(()=>{(async()=>{if(b.id){const T=`${pt}/events/${b.id}`,y=`${pt}/event-payment/${b.id}`;try{const E=await gs.toDataURL(T).then(A=>A);b.shortUrl?i(b.shortUrl):i(T),b.summaryUrl?a(b.summaryUrl):a(y),s(E)}catch{i(`${T}`)}}})()},[b]);const f=C=>{const T=!C.target.checked;o(T),g({...b,hideProgressBar:T})},l=C=>{const T=!C.target.checked;u(T),g({...b,hideaccountblock:T})},v=C=>{const T=!C.target.checked;x(T),g({...b,hidefeed:T,hideFeed:T})},h=C=>{const T=!C.target.checked;j(T),g({...b,hideDonateOption:T})};return e.jsxs("div",{className:"admin-event-urls-component",children:[e.jsxs("div",{className:"admin-event-url-blockz",children:[e.jsxs("div",{className:"inlineadmin-block",children:[e.jsx("div",{className:"headings",children:"Manage Page Sections"}),e.jsx("div",{className:"subheading",children:"Select elements to display on the donor page"})]}),e.jsxs("div",{className:"q-code",children:[e.jsx("div",{className:"qr-code",children:e.jsxs("label",{className:"labelbar",children:[e.jsx("input",{type:"checkbox",checked:!n,onChange:f}),e.jsx("span",{className:"checkbox-text",children:"Progress bar"})]})}),e.jsx("div",{className:"qr-code",children:e.jsxs("label",{className:"labelbar",children:[e.jsx("input",{type:"checkbox",checked:!d,onChange:l}),e.jsx("span",{className:"checkbox-text",children:"Access your account"})]})}),e.jsx("div",{className:"qr-code",children:e.jsxs("label",{className:"labelbar",children:[e.jsx("input",{type:"checkbox",checked:!p,onChange:v}),e.jsx("span",{className:"checkbox-text",children:"Activity feed"})]})}),e.jsx("div",{className:"qr-code",children:e.jsxs("label",{className:"labelbar",children:[e.jsx("input",{type:"checkbox",checked:!N,onChange:h}),e.jsx("span",{className:"checkbox-text",children:"Donate Option"})]})})]})]}),e.jsxs("div",{className:"admin-event-url-block",children:[e.jsx("div",{className:"inlineadmin-block",children:e.jsx("div",{className:"headings",children:"Event Page"})}),e.jsx("div",{className:"q-code",children:e.jsxs("div",{className:"links",children:[e.jsx("div",{className:"label",children:" "}),e.jsx("div",{className:"copy-url-container",children:e.jsx(Ot,{rounded:!0,plainText:!0,text:r,index:1,label:"Event Page URL"})})]})})]})]})},Tn=t=>{const{allCampaigns:s}=X(i=>i.campaign);return s.find(i=>i.campaignId===t)},En=()=>{const{event:t}=c.useContext(R),s=Tn(t.id),r=c.useRef(null);return K.useEffect(()=>{new URLSearchParams(window.location.search).get("socialMedia")==="true"&&r.current&&s&&window.scrollTo({top:document.documentElement.scrollHeight-r.current.offsetHeight-280,behavior:"smooth"})},[t,s]),e.jsx("div",{})},xt="We are going to this event do you wanna go ?",wn=({event:t})=>{const s=c.useRef(null),[r,i]=c.useState(""),[m,a]=c.useState(!1),n=o=>{s.current&&!s.current.contains(o.target)&&a(!1)};return c.useEffect(()=>(document.addEventListener("click",n,!0),()=>{document.removeEventListener("click",n,!0)})),c.useEffect(()=>{(async()=>{const d=window.location.href;try{const p={"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("token")}`,"Access-Control-Allow-Origin":at},x={url:d},b=(await Ct.post(at,x,{headers:p})).data.shortCode;i(`${xt}\r 9https://infq.cc/${b}`)}catch(u){console.log("Error generating short link",u.message),i(`${xt}\r 10${d}`)}})()},[]),e.jsx("div",{className:"campaign-cause-project-search-component",children:e.jsxs("div",{className:"share-container",ref:s,children:[e.jsxs("span",{className:"share-click","data-test":"share-click",onClick:()=>a(!m),children:[e.jsx(ga,{className:"share"})," ",e.jsx("span",{children:"Â Share"})]}),m&&e.jsxs("div",{className:"iframe-section",children:[e.jsxs("div",{className:"heading-container",children:[e.jsx("div",{className:"label",children:"Share with your network"}),e.jsx(Ot,{featureType:"event",featureId:t.eventId,gray:!0,text:r,index:0})]}),e.jsx("textarea",{readOnly:!0,value:r,disabled:!0,style:{width:"100%"},name:"iframe",rows:"3",cols:"50"})]})]})})},Dn=({event:t})=>e.jsxs("div",{className:"event-basic-section-user-view-component",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"event-heading-and-share",children:[e.jsx(se,{type:"h3",children:t.eventName?t.eventName:""}),e.jsx(wn,{event:t})]}),e.jsx("p",{children:t.eventSummary?t.eventSummary:""})]}),t.cover?e.jsx("div",{className:"event-basic-section-user-view-container",children:e.jsx("div",{className:`image-container ${t.cover?"present":""}`,children:e.jsx(je,{file:t.cover})})}):""]}),An=({name:t})=>e.jsxs("div",{children:["You need to log in first to contact ",t,"."," ",e.jsx(jt,{to:"/login",children:"Click here to login"})]}),Pn=({event:t})=>{const{currentUser:s}=X(o=>o.user),[r,i]=K.useState(!1),m=()=>i(!0),a=()=>i(!1),n=()=>{s.authenticated?m():Q.warning(e.jsx(An,{name:t.pointOfContact.name}))};return e.jsxs("div",{className:"event-point-of-contact-user-view-component",children:[e.jsx("div",{className:"event-point-of-contact-section-user-view-header"}),e.jsxs("div",{className:"event-point-of-contact-section-user-view-container",children:[e.jsxs("div",{"data-test":"contact-poc",className:"point-of-contact-image-container",onClick:n,children:[t.pointOfContact.
10image?e.jsx(je,{width:"90px",file:t.pointOfContact.image}):e.jsx(Ft,{name:t.pointOfContact.name,width:"90px"}),e.jsx(Va,{"data-test":"message-cpoc"})]}),e.jsxs("div",{className:"point-of-contact-text-container",children:[e.jsx("div",{className:"point-of-contact-name",children:t.pointOfContact.name}),e.jsx("div",{className:"point-of-contact-designation",children:t.pointOfContact.role})]})]}),e.jsx($a,{show:r,handleClose:a,url:`${window.location.origin}/events/${t.id}`,type:"events",poc:t.pointOfContact,fundRaisingObject:{name:t.eventName,id:t.id}})]})},vt=({className:t,eventToUse:s})=>e.jsxs("div",{className:t,children:[e.jsx(Dn,{event:s}),e.jsx(Gs,{event:s}),e.jsx(zs,{event:s}),e.jsx(Pn,{event:s})]}),In=({view:t,usereventdata:s})=>{const r=c.useContext(R),{event:i,section:m,submitFunction:a}=r||{},[n,o]=c.useState(0),d=s||i,u=()=>{a({publish:!0})};return e.jsxs("div",{className:"event-preview-page",children:[t!=="user"&&e.jsxs("div",{className:"publish-header",children:[e.jsx("span",{className:`mobile ${n===1?"active":""}`,onClick:()=>o(1),children:"Mobile"}),e.jsx("span",{className:`desktop ${n===0?"active":""}`,onClick:()=>o(0),children:"Desktop"})]}),t!=="user"&&e.jsx("div",{className:"preview-area",children:n===0?e.jsx("div",{className:"preview",children:e.jsx(vt,{className:"desktop-preview",eventToUse:d})}):e.jsx(vt,{className:"mobile-preview",eventToUse:d})}),t==="admin"&&e.jsx("div",{className:"general-info-section-footer",children:e.jsx(ue,{publish:!0,section:m,onPublish:u})})]})},On=({event:t,info:s})=>{const r=t.checkedIn?parseInt(t.checkedIn,10):0,i=parseInt(t.soldTickets,10)||0,m=parseInt(i)-parseInt(r),a=(n,o)=>{if(typeof n!="number"||typeof o!="number"||o===0)return"0%";const d=(n/o*100).toFixed(2);return`${parseFloat(d)}%`};return e.jsxs("div",{className:"event-attendees-presence-bar-component",children:[e.jsx("span",{className:"percentage",children:e.jsxs("b",{children:[" ",s]})}),e.jsxs("span",{className:"percentage",children:[e.jsx("b",{children:a(m,i)}),e.jsx("p",{children:"(Not Attended)"})]}),e.jsxs("div",{className:"event-target-achieved-bar-body",style:{width:"100%"},children:[e.jsx("div",{className:"progress",children:e.jsx("div",{className:"progress-bar collected-bar",style:{width:a(r,i)}})}),e.jsxs("div",{className:"amount-info",children:[e.jsx("span",{className:"collected",children:e.jsx("div",{className:"label",children:e.jsxs("div",{className:"inner-container",children:["Checked In ",e.jsx("b",{"data-test":"campaign-amount",children:r})]})})}),e.jsx("span",{className:"remaining",children:e.jsx("div",{className:"label",children:e.jsxs("div",{className:"inner-container",children:["Not Attended  ",e.jsx("b",{children:m})]})})})]})]})]})},Fn=()=>{const{event:t}=c.useContext(R),s=fe("currencySymbol"),[r,i]=c.useState([]),[m,a]=c.useState(0),[n,o]=c.useState(0),[d,u]=c.useState(!0);c.useEffect(()=>{if(t&&t.eventId){const x=aa(t);i(x.eventFigures),u(!1);const N=Na(t.eventId,j=>{j.type==="visited"?a(j.count):j.type==="share"&&o(j.count)});return()=>N()}},[t]);const p=[...r,{count:m,label:"Number of Visits"},{count:n,label:"Number of Shares"}];return e.jsx("div",{className:"admin-event-attendees-stats-component",children:e.jsx("div",{className:"event-figure-container",children:d?e.jsx("div",{className:"loading-container",children:e.jsx(Et,{height:130,children:e.jsx(wt,{})})}):e.jsxs(e.Fragment,{children:[p.map((x,N)=>e.jsxs("div",{className:"user-figure",children:[e.jsxs("div",{className:"amount",children:[x.amount&&s,x.amount||x.count]}),e.jsx("div",{className:"label",children:x.label})]},N)),e.jsx("div",{className:"user-figure",children:e.jsx(On,{event:t,info:"Attendance Information"})})]})})})},Ln=t=>{const s=Te(),{confirmationScreenSettings:r,confirmationScreenLoading:i}=X(h=>h.events),{visibilityOptions:m,accordionOptions:a,savedVisibilityOptions:n,savedAccordionOptions:o}=r;c.useEffect(()=>{t&&s(ka(t))},[t,s]);const d=h=>{s(Oa(h))},u=h=>{s(Ia(h))},p=(h,C,T)=>{s(Pa(h,C,T))},x=(h,C)=>{s(Aa(h,C))},N=(h,C)=>{s(Da(h,C))},j=(h,C,T)=>{s(wa(h,C,T))},b=(h,C,T,y)=>{s(Ea(h,C,T,y))},g=()=>{s(Ta())},f=async()=>t?await s(Sa(t)):(console.error("Event ID is required to save settings"),{success:!1,error:"Event ID is required"}),l=()=>(console.log("Preview visibility options:",m),console.log("Preview accordion o
10ptions:",a),{visibilityOptions:m,accordionOptions:a}),v=c.useMemo(()=>{if(!(n!=null&&n.length)||!(o!=null&&o.length))return!1;const h=JSON.stringify(m)!==JSON.stringify(n),C=y=>y.map(({expanded:E,...A})=>A),T=JSON.stringify(C(a))!==JSON.stringify(C(o));return h||T},[m,a,n,o]);return{visibilityOptions:m,toggleOption:d,accordionOptions:a,toggleAccordion:u,updateAccordionField:p,toggleAccordionFieldCheckbox:x,addDynamicOption:N,removeDynamicOption:j,updateDynamicOption:b,resetOptions:g,saveOptions:f,previewOptions:l,loading:i,hasUnsavedChanges:v}},Vn=({event:t})=>{const s=t.eventTicketType.value==="paid"?"Paid":"Free",{confirmationScreenSettings:r}=X(j=>j.events),{accordionOptions:i,visibilityOptions:m}=r,a=(j,b,g="")=>{var v;const f=i==null?void 0:i.find(h=>h.id===j);if(!f)return g;const l=(v=f.options)==null?void 0:v.find(h=>h.id===b);return(l==null?void 0:l.value)||g},n=j=>{const b=m==null?void 0:m.find(g=>g.id===j);return(b==null?void 0:b.enabled)??!0},o=(j,b)=>{var l;const g=i==null?void 0:i.find(v=>v.id===j);if(!g)return!1;const f=(l=g.options)==null?void 0:l.find(v=>v.id===b);return(f==null?void 0:f.enabled)??!1},d=(j,b)=>{var l;const g=i==null?void 0:i.find(v=>v.id===j);if(!g)return null;const f=(l=g.options)==null?void 0:l.find(v=>v.id===b);return!f||!f.dynamicOptions||f.dynamicOptions.length===0?null:{question:f.value||"",enabled:f.enabled||!1,options:f.dynamicOptions||[]}},u={headerTitle:a(1,"header-title"),subHeading:a(1,"sub-heading")},p=d(4,"source"),x={noteText:a(1,"note-text"),receiptText:a(2,"receipt-text"),businessPlaceholder:a(2,"business-placeholder-text"),guestListText:a(3,"guest-list-text"),guestHeaderText:a(3,"add-guest-header-text"),emailPlaceholder:a(3,"email-field-placeholder"),namePlaceholder:a(3,"name-field-placeholder"),phonePlaceholder:a(3,"phone-number-field-placeholder"),addGuestText:a(3,"action-text"),ratingQuestion:a(4,"rating"),feedbackPlaceholder:a(4,"feedback"),sourceOptions:p},N={showNoteText:n(1),showBusinessText:n(2),showFeedbackSection:n(3),showReceiptText:n(4),showGuestList:n(5),showRating:o(4,"rating"),showSource:o(4,"source"),showFeedback:o(4,"feedback")};return e.jsxs("div",{className:"event-confirmation-preview-wrapper",children:[e.jsx(Fa,{footerTotal:s==="Paid"?5:0,totalTickets:1,checkoutTicket:{tip:!1},tipAmount:0,customText:u}),e.jsx(La,{totalTickets:1,handleStepValidator:()=>{},customText:x,visibilityConfig:N,isPreview:!0}),e.jsx("div",{className:"event-ticket-footer",children:e.jsx(ke,{variant:"contained",size:"large",fullWidth:!0,onClick:()=>{},children:"Submit"})})]})};var $n=js,Mn=function(){return $n.Date.now()},Rn=Mn,Bn=Ns,$e=Rn,ft=bs,Un="Expected a function",Hn=Math.max,Gn=Math.min;function zn(t,s,r){var i,m,a,n,o,d,u=0,p=!1,x=!1,N=!0;if(typeof t!="function")throw new TypeError(Un);s=ft(s)||0,Bn(r)&&(p=!!r.leading,x="maxWait"in r,a=x?Hn(ft(r.maxWait)||0,s):a,N="trailing"in r?!!r.trailing:N);function j(y){var E=i,A=m;return i=m=void 0,u=y,n=t.apply(A,E),n}function b(y){return u=y,o=setTimeout(l,s),p?j(y):n}function g(y){var E=y-d,A=y-u,I=s-E;return x?Gn(I,a-A):I}function f(y){var E=y-d,A=y-u;return d===void 0||E>=s||E<0||x&&A>=a}function l(){var y=$e();if(f(y))return v(y);o=setTimeout(l,g(y))}function v(y){return o=void 0,N&&i?j(y):(i=m=void 0,n)}function h(){o!==void 0&&clearTimeout(o),u=0,i=d=m=o=void 0}function C(){return o===void 0?n:v($e())}function T(){var y=$e(),E=f(y);if(i=arguments,m=this,d=y,E){if(o===void 0)return b(d);if(x)return clearTimeout(o),o=setTimeout(l,s),j(d)}return o===void 0&&(o=setTimeout(l,s)),n}return T.cancel=h,T.flush=C,T}var qn=zn;const gt=zt(qn),_n=({stroke:t="#98A2B3"})=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("g",{clipPath:"url(#clip0_18795_7794)",children:e.jsx("path",{d:"M6.06065 6.0026C6.21739 5.55705 6.52675 5.18134 6.93395 4.94203C7.34116 4.70271 7.81991 4.61523 8.28544 4.69508C8.75096 4.77493 9.1732 5.01695 9.47737 5.37829C9.78154 5.73963 9.94802 6.19695 9.94732 6.66927C9.94732 8.0026 7.94732 8.66927 7.94732 8.66927M8.00065 11.3359H8.00732M14.6673 8.0026C14.6673 11.6845 11.6826 14.6693 8.00065 14.6693C4.31875 14.6693 1.33398 11.6845 1.33398 8.0026C1.33398 4.32071 4.31875 1.33594 8.00065 1.33594C11.6826 1.33594 14.6673 4.32071 14.6673 8.0026Z",stroke:t,strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0_18795_7794",children:e.jsx("rect",{width:"16",height:"16",fill:"white"})})})]}),Wn=t=>{const{event:s,view:r,canEdit:i,type:m}=t,[a,n]=c.useState(!1);c.useEffect(()=>{const k=F=>{F.key==="Escape"&&a&&n(!1)};return a&&document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[a]);const o=()=>{n(!1)},{visibilityOptions:d,toggleOption:u,accordionOptions:p,toggleAccordion:x,updateAccordionField:N,toggleAccordionFieldCheckbox:j,addDynamicOption:b,removeDynamicOption:g,updateDynamicOption:f,saveOptions:l,previewOptions:v,loading:h,hasUnsavedChanges:C}=Ln(s==null?void 0:s.eventId);console.log("loading",h.loading);const[T,y]=c.useState({}),E=c.useRef(gt((k,F,D)=>{N(k,F,D)},300)).current,A=c.useRef(gt((k,F,D,B)=>{f(k,F,D,B)},300)).current;c.useEffect(()=>()=>
10{E.cancel(),A.cancel()},[E,A]);const I=c.useCallback((k,F,D)=>{const B=`${k}-${F}`;y(Y=>({...Y,[B]:D})),E(k,F,D)},[E]),z=c.useCallback((k,F,D,B)=>{const Y=`${k}-${F}-${D}`;y(S=>({...S,[Y]:B})),A(k,F,D,B)},[A]),M=c.useCallback((k,F,D)=>{const B=`${k}-${F}`;return T.hasOwnProperty(B)?T[B]:D},[T]),V=c.useCallback((k,F,D,B)=>{const Y=`${k}-${F}-${D}`;return T.hasOwnProperty(Y)?T[Y]:B},[T]),Z=c.useCallback(async()=>{try{const k=await l();if(k!=null&&k.success)Q.success("Confirmation screen settings saved successfully!"),y({});else{const F=(k==null?void 0:k.error)||"Failed to save settings. Please try again.";Q.error(F)}}catch(k){console.error("Error in handleSave:",k),Q.error("An unexpected error occurred. Please try again.")}},[l]),W=c.useCallback(()=>{v(),n(!0)},[v]),ae=c.useCallback(k=>{if(k===2){const F=d.find(D=>D.id===4);if(!(F!=null&&F.enabled))return}u(k)},[u,d]),ee=c.useCallback(k=>{x(k)},[x]),te=c.useCallback((k,F)=>{j(k,F)},[j]),ie=c.useCallback((k,F)=>{b(k,F)},[b]),de=c.useCallback((k,F,D)=>{g(k,F,D)},[g]);return e.jsxs("div",{className:"event-confirmation-screen-component",children:[e.jsxs("div",{className:"event-confirmation-screen-header",children:[e.jsxs("div",{className:"event-confirmation-screen-header-content",children:[e.jsx(se,{type:"h3",children:"Confirmation screen visibility"}),e.jsx("p",{className:"_description",children:"Choose which sections donors see after a successful purchase and customize them."})]}),e.jsxs("div",{className:"btns-container",children:[e.jsx(ke,{variant:"outlined",color:"primary",onClick:W,children:"Preview"}),e.jsx(ke,{variant:"contained",color:"primary",onClick:Z,disabled:h.loading||!C,loading:h.loading,children:"Save"})]})]}),e.jsxs("div",{className:"event-confirmation-screen-content",children:[e.jsx("div",{className:"event-visibility-options",children:d.map(k=>{var B;const F=(B=d.find(Y=>Y.id===4))==null?void 0:B.enabled,D=k.id===2&&!F;return e.jsxs("div",{className:`event-visibility-option ${D?"disabled":""}`,onClick:()=>
10!D&&ae(k.id),style:{opacity:D?.5:1,cursor:D?"not-allowed":"pointer"},children:[e.jsx(nt,{checked:k.enabled,onChange:()=>ae(k.id),checkmarkColor:"#E68F08",onClick:Y=>Y.stopPropagation(),disabled:D}),e.jsxs("div",{className:"event-visibility-option-content",children:[e.jsx("div",{className:"event-visibility-option-heading",children:k.heading}),e.jsx("div",{className:"event-visibility-option-sub-title",children:k.subTitle})]})]},k.id)})}),e.jsx("div",{className:"event-accordion-options-divider"}),e.jsx("div",{className:"event-accordion-options",children:p.map((k,F)=>e.jsxs(K.Fragment,{children:[e.jsxs(Cs,{expanded:k.expanded,onChange:()=>ee(k.id),className:"accordion-container",children:[e.jsx(ys,{expandIcon:e.jsx(ks,{}),"aria-controls":`panel${k.id}-content`,className:"accordion-header",children:k.heading}),e.jsx(Gt,{className:"accordion-content",children:e.jsx("div",{className:"accordion-fields",children:k.options.map(D=>{if(D.type==="description")return e.jsx("div",{className:"accordion-description",children:D.value},D.id);const B=M(k.id,D.id,D.value),Y=(B==null?void 0:B.length)||0,S=Y>=D.maxLength,w=D.type==="checkbox-input",$=D.dynamicOptions||[],_=$.length<5&&w;return e.jsxs("div",{className:"accordion-field",children:[w&&e.jsxs("div",{className:"checkbox-field-wrapper",children:[e.jsx(nt,{checked:D.enabled||!1,onChange:()=>te(k.id,D.id),checkmarkColor:"#E68F08"}),e.jsx("span",{className:"checkbox-label",children:D.label})]}),e.jsxs("div",{className:"accordion-field-wrapper",children:[e.jsx("div",{className:"input-container",children:e.jsx(it,{label:w?"":D.label,value:M(k.id,D.id,D.value),onChange:U=>{const L=U.target.value;(!D.maxLength||L.length<=D.maxLength)&&I(k.id,D.id,L)},disabled:w&&!D.enabled,sx:{width:"350px"},multiline:D.type==="textarea",rows:D.type==="textarea"?4:1,InputProps:{endAdornment:D.infoText&&e.jsx(Ss,{title:D.infoText,placement:"top",children:e.jsx(Pe,{sx:{p:0},children:e.jsx(_n,{stroke:"#667085"})})})}})}),D.maxLength&&e.jsxs("div",{className:`character-count ${S?"at-limit":""}`,children:[Y,"/",D.maxLength," characters"]})]}),w&&D.dynamicOptions&&e.jsxs("div",{className:"dynamic-options-section",children:[$.map((U,L)=>e.jsxs("div",{className:"dynamic-option-item",children:[e.jsx("div",{className:"dynamic-option-label-wrapper",children:e.jsxs("div",{className:"dynamic-option-label",children:[U.label,e.jsx("div",{className:"remove-button",onClick:()=>de(k.id,D.id,U.id),children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M2.5 6H9.5",stroke:"#98A2B3","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})})})]})}),e.jsx("div",{className:"dynamic-option-input-wrapper",children:e.jsx(it,{value:V(k.id,D.id,U.id,U.value),onChange:P=>{const q=P.target.value;(!U.maxLength||q.length<=U.maxLength)&&z(k.id,D.id,U.id,q)},placeholder:"Enter option",sx:{width:"350px"}})})]},U.id)),e.jsx("div",{className:"add-option-wrapper",children:e.jsx(ke,{variant:"text",color:"primary",size:"small",className:"add-option-btn",onClick:()=>{_&&D.enabled&&ie(k.id,D.id)},disabled:!_||!D.enabled,startIcon:e.jsx(Ts,{}),children:$.length>=5?"Maximum 5 options allowed":"Add more options"})})]})]},D.id)})})})]}),F<p.length-1&&e.jsx("div",{className:"event-accordion-divider"})]},k.id))})]}),e.jsx("div",{className:`event-preview-backdrop ${a?"backdrop-visible":"backdrop-hidden"}`,onClick:o}),e.jsx("div",{className:`event-preview-modal ${a?"preview-visible":"preview-hidden"}`,children:e.jsxs("div",{className:"preview-modal-content",onClick:k=>k.stopPropagation(),children:[e.jsx("div",{className:"preview-close-btn",onClick:()=>n(!1),children:e.jsx(ya,{stroke:"#98A2B3"})}),e.jsx("div",{className:"preview-modal-body",children:e.jsx(Vn,{event:s})})]})})]})},Vt=({canEdit:t,view:s,contribution:r,ignoreBlocking:i})=>{const{event:m,eventEdit:a,updated:n}=c.useContext(R),[o,d]=c.useState(!1),[u,p]=c.useState(!1),[x,N]=c.useState(!1),{pathname:j,search:b}=qt(),g=ve(),f=Re().eventPage,l=He(m.id),v=Es(b,"tab");return c.useEffect(()=>{JSON.stringify(l||kt)!==JSON.stringify(m)?N(!0):N(!1)},[l,m]),c.useEffect(()=>{ws({event:m}).errors.length,d(x)},[x,m]),e.jsxs("div",{className:`events-template-action-component ${n||x?"max-padding":""} `,children:[s==="admin"&&e.jsx("div",{className:"events-template-admin-view-header",children:e.jsx(an,{preview:u,setPreview:p,draftButton:f!=="edit",edited:x,setEdited:N,initialEvent:l,isPublishEnabled:o})}),s==="admin"&&f==="edit"&&a&&e.jsxs("div",{children:[e.jsx(kn,{eventEdit:a}),e.jsx(Fn,{})]}),s==="admin"&&f==="edit"&&e.jsxs("div",{className:"admin-urls-event",children:[e.jsx(Sn,{event:m}),(m.soldTickets===0||m.soldTickets>0)&&e.jsx(yn,{event:m})]}),s==="admin"&&f==="edit"&&e.jsxs("div",{className:"tabs",children:[e.jsx("div",{className:"live-event",children:e.jsx(ye,{"data-test":"event-detail-tab",title:"Event Details",active:!v,btnClickFunction:()=>g(j)})}),e.jsx("div",{className:"event-participants",children:e.jsx(ye,{"data-test":"event-participants-tab",title:"Event Attendees",active:v==="attendees",btnClickFunction:()=>g(`${j}?tab=attendees`)})}),e.jsx("div",{className:"confirmation-screen",children:e.jsx(ye,{"data-test":"confirmation-screen-tab",title:"Confirmation Screen",active:v==="confirmation-screen",btnClickFunction:()=>g(`${j}?tab=confirmation-screen`)})}),e.jsx("div",{className:"event-utm-links",children:e.jsx(ye,{"data-test":"utm-links-tab",title:"Links",active:v==="utm-links",btnClickFunction:()=>g(`${j}?tab=utm-links`)})}),e.jsx("div",{className:"event-audit-logs",children:e.jsx(ye,{"data-test":"audit-logs-tab",title:"Audit Logs",active:v==="audit-logs",btnClickFunction:()=>g(`${j}?tab=audit-logs`)})})]}),!v&&(u?e.jsx(In,{}):e.jsx(ln,{canEdit:t,view:s,contribution:r,ignoreBlocking:i})),s==="admin"&&f==="edit"&&{participants:e.jsx(ht,{}),"event-posts":e.jsx(En,{name:"Event",view:s}),"related-outreach":e.jsx(Ca,{showDrafts:!1,id:m.id,type:m.eventName}),attendees:e.jsx(ht,{}),"audit-logs":e.jsx(ma,{id:m.id,type:"event",campaign:m}),"utm-links":e.jsx(na,{type:"event",campaign:m}),"confirmation-screen":e.jsx(Wn,{event:m,view:s,canEdit:t,type:"event"})}[v]]})},Yn=()=>{const t=ve(),{setIsCreate:s,eventEdit:r,setEvent:i}=c.useContext(R);return c.useEffect(()=>{r?i(Ds.cloneDeep(r)):t("/events/all-events")},[r,t,i]),K.useEffect(()=>{s&&s(!0)},[s]),e.jsx("div",{className:"admin-campaign-draft-page",children:e.jsx(Vt,{view:"admin",canEdit:!0,ignoreBlocking:!r})})},Kn=({disableDraft:t})=>{const{event:s,setIsCreate:r}=c.useContext(R);return K.useEffect(()=>{r(!1)},[r]),e.jsx("div",{className:"admin-campaign-edit-page",children:s&&e.jsx(Vt,{view:"admin",canEdit:!0,disableDraft:t})})},Ur=()=>{const{eventPage:t}=Re();return e.jsx("div",{children:e.jsx(qs,{children:{"all-events":e.jsx(Ga,{}),create:e.jsx(sn,{}),draft:e.jsx(Yn,{}),edit:e.jsx(Kn,{})}[t]})})};export{Ur 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.