PageSourceSearch

https://eventpulse.ng/assets/BudgetManagement-DEaJqWm_.js

js eventpulse.ng collected 2026-10-04 01:48:34 UTC 87,512 bytes, 559 lines download raw bytes

1import{j as e,F as B,C as U,u as ge,a as fe,b as Te,s as Le}from"./index-CsSXqz7N.js";import{r as x,b as ft,L as yt,h as vt}from"./vendor-react-DPmWmpvI.js";import{E as jt,a as te}from"./vendor-pdf-xZJ_zfOo.js";import{x as Nt,X as ee,D as ke,cY as ue,b1 as Ie,S as Be,T as pe,a as $e,m as we,av as he,i as St,C as Ce,c4 as Ue,j as Oe,y as wt,b2 as Ct,P as Z,aV as Tt,cf as xe,aP as le,aR as _e}from"./vendor-ui-DBK2XfYL.js";import"./vendor-canvas-B-q-NmKy.js";const kt=(c,r,y,E,s,C,m,v,D={})=>{if(!c){m("Please select an event first");return}const{includeExpenses:L=!0,includeRevenue:i=!0,includeSummary:b=!0,reportStyle:j="full",categories:g=[],expenseStatus:f="all",revenueStatus:I="all",dateFrom:d="",dateTo:T="",reportTitle:_="",preparedFor:A=""}=D;let $=[...E];if(g.length>0&&($=$.filter(p=>g.includes(p.category))),f!=="all"&&($=$.filter(p=>p.status===f)),d){const p=new Date(d);$=$.filter(o=>o.date&&new Date(o.date)>=p)}if(T){const p=new Date(T);$=$.filter(o=>o.date&&new Date(o.date)<=p)}let n=[...s];if(I!=="all"&&(n=n.filter(p=>p.status===I)),d){const p=new Date(d);n=n.filter(o=>o.date&&(o.date==="Ongoing"||new Date(o.date)>=p))}if(T){const p=new Date(T);n=n.filter(o=>o.date&&(o.date==="Ongoing"||new Date(o.date)<=p))}const a=new jt,P=a.internal.pageSize.width,R=a.internal.pageSize.height,S=[219,39,119];let l=20;const u=56;a.setFillColor(...S),a.rect(0,0,P,u,"F"),a.setFillColor(170,15,80),a.rect(0,u-3,P,3,"F"),a.setFontSize(7.5),a.setFont("helvetica","bold"),a.setTextColor(255,210,232),a.text((_||"BUDGET & FINANCE REPORT").toUpperCase(),14,13),a.setFontSize(7.5),a.setFont("helvetica","normal"),a.setTextColor(255,210,232),a.text(`Generated: ${new Date().toLocaleDateString()}`,P-14,13,{align:"right"});const q=r?.title||_||"Budget Report";a.setFontSize(20),a.setFont("helvetica","bold"),a.setTextColor(255,255,255);const G=a.splitTextToSize(q,P-80);a.text(G,14,30);const H=[];if(H.push(`By ${C}`),r?.startDate&&H.push(new Date(r.startDate).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})),r?.location&&H.push(r.location),H.length>0){const p=30+G.length*8+6;a.setFontSize(8),a.setFont("helvetica","normal"),a.setTextColor(255,220,240),a.text(H.join("   ·   "),14,Math.min(p,u-6))}l=u+10,A&&(a.setFillColor(248,250,252),a.setDrawColor(200,200,200),a.setLineWidth(.3),a.roundedRect(15,l,P-30,12,2,2,"FD"),a.setFontSize(9),a.setFont("helvetica","normal"),a.setTextColor(80,80,80),a.text(`Prepared for: ${A}`,20,l+8),l+=18),a.setFillColor(248,250,252),a.setDrawColor(...S),a.setLineWidth(.5),a.roundedRect(15,l,P-30,28,3,3,"FD"),a.setFillColor(...S),a.circle(23,l+8,3,"F"),a.setTextColor(0,0,0),a.setFontSize(16),a.setFont("helvetica","bold");const K=r?.title||"Event Name",h=a.splitTextToSize(K,P-60);a.text(h,30,l+10),a.setFontSize(9),a.setFont("helvetica","normal"),a.setTextColor(100,100,100);let O="";if(r?.startDate){if(O=new Date(r.startDate).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"}
1),r?.endDate&&r.endDate!==r.startDate){const o=new Date(r.endDate);O+=` – ${o.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})}`}r?.startTime&&(O+=` at ${r.startTime}`,r?.endTime&&(O+=` – ${r.endTime}`))}else O="Date not specified";a.text(O,30,l+10+h.length*6+4),l+=36;const Y=[];if(g.length>0&&Y.push(`Categories: ${g.join(", ")}`),f!=="all"&&Y.push(`Expense status: ${f}`),I!=="all"&&Y.push(`Revenue status: ${I}`),(d||T)&&Y.push(`Date range: ${d||"…"} → ${T||"…"}`),j!=="full"&&Y.push(`Style: ${j==="summary"?"Summary only":"Executive view"}`),Y.length>0&&(a.setFontSize(8),a.setFont("helvetica","italic"),a.setTextColor(130,130,130),a.text(`Filters applied — ${Y.join(" · ")}`,15,l),l+=10),b&&j!=="executive"){a.setFontSize(12),a.setFont("helvetica","bold"),a.setTextColor(...S),a.text("Financial Summary",15,l),l+=8;const p=$.reduce((M,J)=>M+Number(J.amount||0),0),o=n.reduce((M,J)=>M+Number(J.amount||0),0),W=o-p,V=[["Total Revenue",`NGN ${o.toLocaleString()}`],["Total Expenses",`NGN ${p.toLocaleString()}`],["Net Profit/Loss",`NGN ${W.toLocaleString()}`],["Profit Margin",`${o>0?(W/o*100).toFixed(1):0}%`]];te(a,{startY:l,head:[["Metric","Amount"]],body:V,theme:"grid",headStyles:{fillColor:S,textColor:[255,255,255],fontStyle:"bold",fontSize:10},bodyStyles:{fontSize:9},alternateRowStyles:{fillColor:[249,250,251]},margin:{left:15,right:15}}),l=a.lastAutoTable.finalY+15}if(L&&$.length>0){if(a.setFontSize(12),a.setFont("helvetica","bold"),a.setTextColor(...S),a.text("Expense Breakdown",15,l),l+=5,j==="summary"){const p=$.reduce((W,V)=>{const M=V.category||"Other";return W[M]||(W[M]={amount:0,paid:0,balance:0,count:0}),W[M].amount+=Number(V.amount||0),W[M].paid+=Number(V.paidAmount||0),W[M].balance+=Number(V.balance||0),W[M].count+=1,W},{}),o=Object.entries(p).map(([W,V])=>[W,V.count,`NGN ${V.amount.toLocaleString()}`,`NGN ${V.paid.toLocaleString()}`,`NGN ${V.balance.toLocaleString()}`]);te(a,{startY:l,head:[["Category","Items","Total Amount","Paid","Balance"]],body:o,theme:"striped",headStyles:{fillColor:S,textColor:[255,255,255],fontStyle:"bold",fontSize:9},bodyStyles:{fontSize:8},columnStyles:{0:{cellWidth:50},1:{cellWidth:15,halign:"center"},2:{cellWidth:40,halign:"right"},3:{cellWidth:35,halign:"right"},4:{cellWidth:35,halign:"right"}},margin:{left:15,right:15},alternateRowStyles:{fillColor:[249,250,251]}})}else if(j==="executive"){const p=$.map(o=>[o.item||"N/A",o.category||"N/A",o.status||"Pending",o.date?new Date(o.date).toLocaleDateString():"N/A"]);te(a,{startY:l,head:[["Item","Category","Status","Date"]],body:p,theme:"striped",headStyles:{fillColor:S,textColor:[255,255,255],fontStyle:"bold",fontSize:9},bodyStyles:{fontSize:8},columnStyles:{0:{cellWidth:65},1:{cellWidth:45},2:{cellWidth:35},3:{cellWidth:35}},margin:{left:15,right:15},alternateRowStyles:{fillColor:[249,250,251]}})}else{const p=$.map(o=>[o.item||"N/A",o.category||"N/A",`NGN ${Number(o.amount||0).toLocaleString()}`,`NGN ${Number(o.paidAmount||0).toLocaleString()}`,`NGN ${Number(o.balance||0).toLocaleString()}`,o.status||"Pending",o.date?new Date(o.date).toLocaleDateString():"N/A"]);te(a,{startY:l,head:[["Item","Category","Amount","Paid","Balance","Status","Date"]],body:p,theme:"striped",headStyles:{fillColor:S,textColor:[255,255,255],fontStyle:"bold",fontSize:9},bodyStyles:{fontSize:8},columnStyles:{0:{cellWidth:35},1:{cellWidth:25},2:{cellWidth:25,halign:"right"},3:{cellWidth:25,halign:"right"},4:{cellWidth:25,halign:"right"},5:{cellWidth:20},6:{cellWidth:25}},margin:{left:15,right:15},alternateRowStyles:{fillColor:[249,250,251]}})}l=a.lastAutoTable.finalY+15}if(i&&n.length>0){if(l>R-60&&(a.addPage(),l=20),a.setFontSize(12),a.setFont("helvetica","bold"),a.setTextColor(...S),a.text("Revenue Sources",15,l),l+=5,j==="executive"){const p=n.map(o=>[o.source||"N/A",o.type||"Manual",o.status||"Pending",o.date==="Ongoing"?"Ongoing":o.date?new Date(o.date).toLocaleDateString():"N/A"]);te(a,{startY:l,head:[["Source","Type","Status","Date"]],body:p,theme:"striped",headStyles:{fillColor:S,textColor:[255,255,255],fontStyle:"bold",fontSize:9},bodyStyles:{fontSize:8},columnStyles:{0:{cellWidth:65},1:{cellWidth:40},2:{cellWidth:40},3:{cellWidth:35}},margin:{left:15,right:15},alternateRowStyles:{fillColor:[249,250,251]}})}else{const p=n.map(o=>[o.source||"N/A",o.type||"Manual",`NGN ${Number(o.amount||0).toLocaleStr
1ing()}`,o.status||"Pending",o.date==="Ongoing"?"Ongoing":o.date?new Date(o.date).toLocaleDateString():"N/A"]);te(a,{startY:l,head:[["Source","Type","Amount","Status","Date"]],body:p,theme:"striped",headStyles:{fillColor:S,textColor:[255,255,255],fontStyle:"bold",fontSize:9},bodyStyles:{fontSize:8},columnStyles:{0:{cellWidth:50},1:{cellWidth:30},2:{cellWidth:40,halign:"right"},3:{cellWidth:30},4:{cellWidth:30}},margin:{left:15,right:15},alternateRowStyles:{fillColor:[249,250,251]}})}l=a.lastAutoTable.finalY+10}const Q=a.internal.getNumberOfPages();for(let p=1;p<=Q;p++)a.setPage(p),a.setFillColor(245,245,245),a.rect(0,R-20,P,20,"F"),a.setDrawColor(...S),a.setLineWidth(.5),a.line(0,R-20,P,R-20),a.setFontSize(9),a.setTextColor(100,100,100),a.setFont("helvetica","bold"),a.text(`Page ${p} of ${Q}`,15,R-10),a.setFont("helvetica","normal"),a.setFontSize(8),a.setTextColor(128,128,128),a.text("Generated by EventPulse - Event Management Platform",P/2,R-13,{align:"center"}),a.setFontSize(7),a.text("www.eventpulse.ng",P/2,R-7,{align:"center"}),a.setFontSize(8),a.text(new Date().toLocaleString(),P-15,R-10,{align:"right"});const ye=`${(r?.title||"Event").replace(/[^a-z0-9]/gi,"_")}_Budget_Report_${new Date().toISOString().split("T")[0]}.pdf`;a.save(ye),v("PDF exported successfully")},zt=["Paid","Partially Paid","Pending"],Dt=["Received","In Progress","Pending"],Et={includeExpenses:!0,includeRevenue:!0,includeSummary:!0,reportStyle:"full",categories:[],expenseStatus:"all",revenueStatus:"all",dateFrom:"",dateTo:"",reportTitle:"",preparedFor:""},At=({expenses:c,revenueStreams:r,onClose:y,onExport:E})=>{const[s,C]=x.useState(Et),m=x.useMemo(()=>[...new Set(c.map(b=>b.category).filter(Boolean))].sort(),[c]),v=(i,b)=>C(j=>({...j,[i]:b})),D=i=>{C(b=>{const j=b.categories.includes(i)?b.categories.filter(g=>g!==i):[...b.categories,i];return{...b,categories:j}})},L=()=>{E(s),y()};return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.75)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1050,padding:"1rem"},children:e.jsxs("div",{style:{background:"hsl(var(--bg-card))",border:"1px solid hsl(var(--border-color))",borderRadius:"18px",width:"100%",maxWidth:"520px",maxHeight:"90vh",overflowY:"auto",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"1.5rem 1.75rem 1.25rem",borderBottom:"1px solid hsl(var(--border-color))",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("div",{style:{width:"38px",height:"38px",borderRadius:"10px",background:"hsl(var(--primary) / 0.1)",color:"hsl(var(--primary))",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(Nt,{size:18})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:800,fontSize:"1.05rem",color:"hsl(var(--text-main))"},children:"Export Report"}),e.jsx("div",{style:{fontSize:"0.8rem",color:"hsl(var(--text-dim))"},children:"Customise what's included"})]})]}),e.jsx("button",{onClick:y,style:{background:"none",border:"none",color:"hsl(var(--text-dim))",cursor:"pointer",padding:"0.3rem",borderRadius:"6px",lineHeight:0},children:e.jsx(ee,{size:20})})]}),e.jsxs("div",{style:{padding:"1.5rem 1.75rem",display:"flex",flexDirection:"column",gap:"1.5rem",overflowY:"auto"},children:[e.jsx(ce,{label:"What to include",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.6rem"},children:[e.jsx(de,{active:s.includeExpenses,onClick:()=>v("includeExpenses",!s.includeExpenses),label:"Expenses"}),e.jsx(de,{active:s.includeRevenue,onClick:()=>v("includeRevenue",!s.includeRevenue),label:"Revenue"}),e.jsx(de,{active:s.includeSummary,onClick:()=>v("includeSummary",!s.includeSummary),label:"Summary totals"})]})}),e.jsx(ce,{label:"Report style",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[{value:"full",label:"Full detail",desc:"Every line item with amounts"},{value:"summary",label:"Summary only",desc:"Totals per category, no individual lines"},{value:"executive",label:"Executive view",desc:"Categories & status only — amounts hidden"}].map(i=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.75rem 1rem",background:s.reportStyle===i.value?"hsl(var(--primary) / 0.08)":"hsl(var(--bg-dark) / 0.4)",border:`1.5px solid ${s.reportStyle===i.value?"hsl(var(--primary) / 0.4)":"hsl(var(--border-color))"}`,borderRadius:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:"reportStyle",value:i.value,checked:s.reportStyle===i.value,onChange:()=>v("reportStyle",i.value),style:{accentColor:"hsl(var(--primary))",flexShrink:0}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:700,fontSize:"0.9rem",color:"hsl(var(--text-main))"},children:i.label}),e.jsx("div",{style:{fontSize:"0.78rem",color:"hsl(var(--text-dim))"},children:i.desc})]})]},i.value))})}),m.length>0&&e.jsx(ce,{label:"Filter by category",hint:"Leave all unselected to include all",children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.5rem"},children:m.map(i=>e.jsx(de,{active:s.categories.length===0||s.categories.includes(i),onClick:()=>D(i),label:i,small:!0},i))})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1rem"},children:[e.jsxs("div",{children:[e.jsx(oe,{label:"Expense status"}),e.jsxs("select",{value:s.expenseStatus,onChange:i=>v("expenseStatus",i.target.value),style:Me,children:[e.jsx("option",{value:"all",children:"All statuses"}),zt.map(i=>e.jsx("option",{value:i,children:i},i))]})]}),e.jsxs("div",{children:[e.jsx(oe,{label:"Revenue status"}),e.jsxs("select",{value:s.revenueStatus,onChange:i=>v("revenueStatus",i.target.value),style:Me,children:[e.jsx("option",{value:"all",children:"All statuses"}),Dt.map(i=>e.jsx("option",{value:i,children:i},i))]})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1rem"},children:[e.jsxs("div",{children:[e.jsx(oe,{label:"Date from"}),e.jsx("input",{type:"date",value:s.dateFrom,onChange:i=>v("dateFrom",i.target.value),style:me})]}),e.jsxs("div",{children:[e.jsx(oe,{label:"Date to"}),e.jsx("input",{type:"date",value:s.dateTo,onChange:i=>v("dateTo",i.target.value),style:me})]})]}),e.jsx(ce,{label:"Recipient context",hint:"Optional — appears on the cover",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsx("input",{type:"text",placeholder:"Report title (e.g. Finance Review Q1)",value:s.reportTitle,onChange:i=>v("reportTitle",i.target.value),style:me}),e.jsx("input",{type:"text",placeholder:"Prepared for (e.g. Finance C
1ommittee)",value:s.preparedFor,onChange:i=>v("preparedFor",i.target.value),style:me})]})})]}),e.jsxs("div",{style:{padding:"1.25rem 1.75rem",borderTop:"1px solid hsl(var(--border-color))",display:"flex",gap:"0.75rem",justifyContent:"flex-end",flexShrink:0},children:[e.jsx("button",{onClick:y,style:{padding:"0.7rem 1.4rem",background:"transparent",border:"1.5px solid hsl(var(--border-color))",borderRadius:"10px",color:"hsl(var(--text-dim))",fontWeight:600,cursor:"pointer",fontSize:"0.9rem",fontFamily:"inherit"},children:"Cancel"}),e.jsxs("button",{onClick:L,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.7rem 1.4rem",background:"hsl(var(--primary))",border:"none",borderRadius:"10px",color:"white",fontWeight:700,cursor:"pointer",fontSize:"0.9rem",fontFamily:"inherit"},children:[e.jsx(ke,{size:16}),"Generate PDF"]})]})]})})},oe=({label:c})=>e.jsx("div",{style:{fontSize:"0.78rem",fontWeight:700,color:"hsl(var(--text-dim))",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"0.5rem"},children:c}),ce=({label:c,hint:r,children:y})=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"0.6rem",display:"flex",alignItems:"baseline",gap:"0.4rem"},children:[e.jsx("span",{style:{fontSize:"0.78rem",fontWeight:700,color:"hsl(var(--text-dim))",textTransform:"uppercase",letterSpacing:"0.06em"},children:c}),r&&e.jsxs("span",{style:{fontSize:"0.75rem",color:"hsl(var(--text-dim))",opacity:.65},children:["— ",r]})]}),y]}),de=({active:c,onClick:r,label:y,small:E})=>e.jsx("button",{type:"button",onClick:r,style:{padding:E?"0.35rem 0.8rem":"0.45rem 1rem",borderRadius:"50px",border:`1.5px solid ${c?"hsl(var(--primary))":"hsl(var(--border-color))"}`,background:c?"hsl(var(--primary) / 0.1)":"transparent",color:c?"hsl(var(--primary))":"hsl(var(--text-dim))",fontWeight:600,fontSize:E?"0.8rem":"0.875rem",cursor:"pointer",transition:"all 0.15s",fontFamily:"inherit"},children:y}),Me={width:"100%",padding:"0.65rem 0.9rem",background:"hsl(var(--bg-dark) / 0.5)",border:"1.5px solid hsl(var(--border-color))",borderRadius:"10px",color:"hsl(var(--text-main))",fontSize:"0.9rem",fontFamily:"inherit",outline:"none",boxSizing:"border-box"},me={width:"100%",padding:"0.65rem 0.9rem",background:"hsl(var(--bg-dark) / 0.5)",border:"1.5px solid hsl(var(--border-color))",borderRadius:"10px",color:"hsl(var(--text-main))",fontSize:"0.9rem",fontFamily:"inherit",outline:"none",boxSizing:"border-box"},ie=c=>c?{uid:c.uid||"",name:c.displayName||c.name||(c.email?c.email.split("@")[0]:"Team Member"),email:c.email||"",role:c.role||"team_member"}:{uid:"system",name:"System / Organizer",email:"",role:"organizer"},be=(c,r,y,E={})=>{const s=ie(c);return{id:`act_${Date.now()}_${Math.random().toString(36).substring(2,7)}`,action:r,actorUid:s.uid,actorName:s.name,actorEmail:s.email,actorRole:s.role,summary:y||"",details:E||{},timestamp:new Date().toISOString()}},ae=async({eventId:c,organizerId:r,user:y,action:E,itemType:s,itemId:C,itemName:m,amount:v=0,before:D=null,after:L=null,summary:i=""})=>{try{(!c||!r)&&console.warn("[BudgetAuditService] Missing eventId or organizerId for audit log:",{eventId:c,organizerId:r});const b=ie(y),j=new Date().toISOString();let g=i;if(!g)switch(E){case"create_expense":g=`${b.name} created expense "${m}" for ₦${Number(v).toLocaleString()}`;break;case"update_expense":g=`${b.name} updated expense "${m}"`;break;case"delete_expense":g=`${b.name} deleted expense "${m}" (Total: ₦${Number(v).toLocaleString()})`;break;case"record_payment":g=`${b.name} recorded a payment of ₦${Number(v).toLocaleString()} for "${m}"`;break;case"create_revenue":g=`${b.name} created revenue source "${m}" for ₦${Number(v).toLocaleString()}`;break;case"update_revenue":g=`${b.name} updated revenue source "${m}"`;break;case"delete_revenue":g=`${b.name} deleted revenue source "${m}" (Amount: ₦${Number(v).toLocaleString()})`;break;default:g=`${b.name} performed ${E} on "${m}"`}const f={eventId:c||"",organizerId:r||"",action:E,itemType:s||"expense",itemId:C||"",itemName:m||"Unnamed Item",amount:Number(v)||0,actor:b,changes:{before:D||null,after:L||null},summary:g,timestamp:j},{id:I,error:d}=await B.add(U.BUDGET_AUDIT_LOGS,f);return d?(console.error("[BudgetAuditService] Error saving audit log:",d),{error:d}):{id:I,data:f}}catch(b){return console.error("[BudgetAuditService] Failed to write audit log:",b),{error:b.message}}},Pt=async(c,r)=>{try{if(!c||!r)return{data:[],error:null};const y=[{field:"eventId",operator:"==",value:c},{field:"organizerId",operator:"==",value:r}],{data:E,error:s}=await B.getAll(U.BUDGET_AUDIT_LOGS,y);if(s)throw new Error(s);return{data:(E||[]).sort((m,v)=>{const D=new Date(m.timestamp||0).getTime();return new Date(v.timestamp||0).getTime()-D}),error:null}}catch(y){return console.error("[BudgetAuditService] Error fetching audit logs:",y),{data:[],error:y.message}}},Rt={create_expense:{label:"Expense Created",badgeClass:"badge-create",icon:St,type:"expense"},update_expense:{label:"Expense Updated",badgeClass:"badge-update",icon:$e,type:"expense"},delete_expense:{label:"Expense Deleted",badgeClass:"badge-delete",icon:pe,type:"expense"},record_payment:{label:"Payment Recorded",badgeClass:"badge-payment",icon:he,type:"payment"},create_revenue:{label:"Revenue Created",badgeClass:"badge-create",icon:we,type:"revenue"},update_revenue:{label:"Revenue Updated",badgeClass:"badge-update",icon:$e,type:"revenue"},delete_revenue:{label:"Revenue Deleted",badgeClass:"badge-delete",icon:pe,type:"revenue"}},Ft=({onClose:c,eventId:r,organizerId:y,eventTitle:E})=>{const{user:s}=ge(),C=s?.role?.startsWith("organizer")||s?.role==="admin",{success:m,error:v}
1=fe(),[D,L]=x.useState([]),[i,b]=x.useState(!0),[j,g]=x.useState(""),[f,I]=x.useState("all"),[d,T]=x.useState(null),_=async()=>{if(!C)return;b(!0);const{data:n,error:a}=await Pt(r,y);a?v("Failed to load budget audit trail"):L(n||[]),b(!1)};if(x.useEffect(()=>{C&&_()},[r,y,C]),!C)return null;const A=x.useMemo(()=>D.filter(n=>{if(f==="expense"&&n.itemType!=="expense"||f==="revenue"&&n.itemType!=="revenue"||f==="payment"&&n.action!=="record_payment"||f==="deletion"&&!n.action.startsWith("delete_"))return!1;if(!j.trim())return!0;const a=j.toLowerCase(),P=(n.actor?.name||"").toLowerCase(),R=(n.actor?.email||"").toLowerCase(),S=(n.itemName||"").toLowerCase(),l=(n.summary||"").toLowerCase();return P.includes(a)||R.includes(a)||S.includes(a)||l.includes(a)}),[D,f,j]),$=()=>{if(D.length===0){v("No audit logs available to export.");return}const n=["Timestamp","Action","Item Type","Item Name","Amount (NGN)","Actor Name","Actor Email","Actor Role","Summary"],a=D.map(u=>[`"${new Date(u.timestamp).toLocaleString()}"`,`"${u.action}"`,`"${u.itemType||"expense"}"`,`"${(u.itemName||"").replace(/"/g,'""')}"`,Number(u.amount)||0,`"${(u.actor?.name||"").replace(/"/g,'""')}"`,`"${u.actor?.email||""}"`,`"${u.actor?.role||""}"`,`"${(u.summary||"").replace(/"/g,'""')}"`]),P=[n.join(","),...a.map(u=>u.join(","))].join(`
2`),R=new Blob([P],{type:"text/csv;charset=utf-8;"}),S=URL.createObjectURL(R),l=document.createElement("a");l.href=S,l.download=`Budget_Audit_Trail_${(E||"Event").replace(/[^a-z0-9]/gi,"_")}_${new Date().toISOString().split("T")[0]}.csv`,l.click(),URL.revokeObjectURL(S),m("Audit trail exported successfully!")};return e.jsxs("div",{className:"modal-overlay bam-overlay",onClick:c,children:[e.jsxs("div",{className:"bam-modal-content anim-scale-in",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"bam-header",children:[e.jsxs("div",{className:"bam-header-left",children:[e.jsx("div",{className:"bam-header-icon",children:e.jsx(ue,{size:22})}),e.jsxs("div",{children:[e.jsxs("div",{className:"bam-title-row",children:[e.jsx("h2",{className:"bam-title",children:"Financial Audit Trail"}),e.jsx("span",{className:"bam-live-badge",children:"Immutable Log"})]}),e.jsxs("p",{className:"bam-subtitle",children:["Complete timeline of all budget creations, edits, payments, and deletions for ",e.jsx("strong",{children:E||"this event"}),"."]})]})]}),e.jsxs("div",{className:"bam-header-actions",children:[e.jsxs("button",{className:"bam-btn-outline",onClick:_,disabled:i,title:"Refresh Audit Logs",children:[e.jsx(Ie,{size:15,className:i?"bam-spin":""}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"bam-btn-primary",onClick:$,disabled:D.length===0,title:"Download CSV report of all financial actions",children:[e.jsx(ke,{size:15}),e.jsx("span",{children:"Export CSV"})]}),e.jsx("button",{className:"bam-close-btn",onClick:c,"aria-label":"Close modal",children:e.jsx(ee,{size:20})})]})]}),e.jsxs("div",{className:"bam-toolbar",children:[e.jsxs("div",{className:"bam-tabs",children:[e.jsxs("button",{className:`bam-tab ${f==="all"?"active":""}`,onClick:()=>I("all"),children:["All Actions ",e.jsx("span",{className:"bam-tab-count",children:D.length})]}),e.jsxs("button",{className:`bam-tab ${f==="expense"?"active":""}`,onClick:()=>I("expense"),children:["Expenses ",e.jsx("span",{className:"bam-tab-count",children:D.filter(n=>n.itemType==="expense").length})]}),e.jsxs("button",{className:`bam-tab ${f==="revenue"?"active":""}`,onClick:()=>I("revenue"),children:["Revenue ",e.jsx("span",{className:"bam-tab-count",children:D.filter(n=>n.itemType==="revenue").length})]}),e.jsxs("button",{className:`bam-tab ${f==="payment"?"active":""}`,onClick:()=>I("payment"),children:["Payments ",e.jsx("span",{className:"bam-tab-count",children:D.filter(n=>n.action==="record_payment").length})]}),e.jsxs("button",{className:`bam-tab ${f==="deletion"?"active":""}`,onClick:()=>
2I("deletion"),children:["Deletions ",e.jsx("span",{className:"bam-tab-count",children:D.filter(n=>n.action.startsWith("delete_")).length})]})]}),e.jsxs("div",{className:"bam-search-box",children:[e.jsx(Be,{size:15,className:"bam-search-icon"}),e.jsx("input",{type:"text",placeholder:"Search by actor, item name, or summary...",value:j,onChange:n=>g(n.target.value),className:"bam-search-input"}),j&&e.jsx("button",{className:"bam-search-clear",onClick:()=>g(""),children:e.jsx(ee,{size:13})})]})]}),e.jsx("div",{className:"bam-body",children:i?e.jsxs("div",{className:"bam-loading-state",children:[e.jsx(Ie,{size:36,className:"bam-spin text-primary"}),e.jsx("h4",{children:"Loading Financial Audit Logs..."}),e.jsx("p",{children:"Verifying ledger and chronological activity trail."})]}):A.length===0?e.jsxs("div",{className:"bam-empty-state",children:[e.jsx("div",{className:"bam-empty-icon",children:e.jsx(ue,{size:36})}),e.jsx("h4",{children:j?"No matching audit records found":"No audit records yet"}),e.jsx("p",{children:j?`No actions match "${j}". Try a different keyword.`:"Financial activities (additions, modifications, payments, and deletions) will automatically be recorded here in real-time."})]}):e.jsx("div",{className:"bam-timeline",children:A.map(n=>{const a=Rt[n.action]||{label:n.action,badgeClass:"badge-default",icon:ue},P=a.icon,R=d===n.id,S=n.changes&&(n.changes.before||n.changes.after);return e.jsxs("div",{className:`bam-log-card ${a.badgeClass}`,children:[e.jsxs("div",{className:"bam-log-main-row",children:[e.jsx("div",{className:`bam-action-icon-box ${a.badgeClass}`,children:e.jsx(P,{size:18})}),e.jsxs("div",{className:"bam-log-info",children:[e.jsxs("div",{className:"bam-log-top-line",children:[e.jsx("span",{className:`bam-action-pill ${a.badgeClass}`,children:a.label}),e.jsxs("span",{className:"bam-item-tag",children:[n.itemType==="revenue"?"Revenue":"Expense",": ",e.jsx("strong",{children:n.itemName})]}),n.amount>0&&e.jsxs("span",{className:"bam-amount-badge",children:["₦",Number(n.amount).toLocaleString()]})]}),e.jsx("p",{className:"bam-log-summary",children:n.summary}),e.jsxs("div",{className:"bam-meta-row",children:[e.jsxs("div",{className:"bam-actor-chip",children:[e.jsx("div",{className:"bam-actor-avatar",children:(n.actor?.name?.[0]||"U").toUpperCase()}),e.jsx("span",{className:"bam-actor-name",children:n.actor?.name||"Unknown User"}),e.jsxs("span",{className:"bam-actor-role",children:["(",n.actor?.role==="organizer"||n.actor?.role?.startsWith("organizer")?"Organizer":n.actor?.role==="admin"?"Admin":"Staff",")"]}),n.actor?.email&&e.jsxs("span",{className:"bam-actor-email",children:["<",n.actor.email,">"]})]}),e.jsxs("span",{className:"bam-timestamp",children:[e.jsx(Ce,{size:12}),new Date(n.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})]})]})]}),S&&e.jsx("button",{className:"bam-diff-toggle-btn",onClick:()=>T(R?null:n.id),title:R?"Hide change details":"View change diff",children:R?"Hide Details":"View Changes"})]}),R&&S&&e.jsx("div",{className:"bam-diff-drawer anim-slide-in",children:e.jsxs("div",{className:"bam-diff-grid",children:[n.changes.before&&e.jsxs("div",{className:"bam-diff-col before",children:[e.jsx("span",{className:"bam-diff-header",children:"Before"}),e.jsx("div",{className:"bam-diff-content",children:Object.entries(n.changes.before).map(([l,u])=>e.jsxs("div",{className:"bam-diff-item",children:[e.jsxs("span",{className:"bam-diff-key",children:[l,":"]}),e.jsx("span",{className:"bam-diff-val",children:typeof u=="number"?`₦${u.toLocaleString()}`:String(u||"—")})]},l))})]}),n.changes.after&&e.jsxs("div",{className:"bam-diff-col after",children:[e.jsx("span",{className:"bam-diff-header",children:"After (Updated)"}),e.jsx("div",{className:"bam-diff-content",children:Object.entries(n.changes.after).map(([l,u])=>e.jsxs("div",{className:"bam-diff-item",children:[e.jsxs("span",{className:"bam-diff-key",children:[l,":"]}),e.jsx("span",{className:"bam-diff-val",children:typeof u=="number"?`₦${u.toLocaleString()}`:String(u||"—")})]},l))})]})]})})]},n.id)})})}),e.jsxs("div",{className:"bam-footer",children:[e.jsxs("div",{className:"bam-footer-info",children:[e.jsx(Ue,{size:14,className:"text-primary"}),e.jsx("span",{children:"Every entry is stamped with cryptographic actor attributes and cannot be altered or removed."})]}),e.jsx("button",{className:"bam-btn-outline",onClick:c,children:"Close"})]})]}),e.jsx("style",{children:`
3                .bam-overlay {
4                    position: fixed;
5                    inset: 0;
6                    background: rgba(0, 0, 0, 0.78);
7                    backdrop-filter: blur(10px);
8                    -webkit-backdrop-filter: blur(10px);
9                    display: flex;
10                    align-items: center;
11                    justify-content: center;
12                    z-index: 1000;
13                    padding: 1rem;
14                }
15
16                .bam-modal-content {
17                    width: 100%;
18                    max-width: 960px;
19                    max-height: 90vh;
20                    background: hsl(var(--bg-card, 240 10% 4%));
21                    border: 1px solid hsl(var(--border-color, 240 6% 18%));
22                    border-radius: 20px;
23                    display: flex;
24                    flex-direction: column;
25                    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 35px -5px hsl(var(--primary) / 0.15);
26                    overflow: hidden;
27                }
28
29                /* Header */
30                .bam-header {
31                    display: flex;
32                    align-items: center;
33                    justify-content: space-between;
34                    padding: 1.25rem 1.75rem;
35                    border-bottom: 1px solid hsl(var(--border-color));
36                    background: hsl(var(--bg-secondary) / 0.4);
37                }
38
39                .bam-header-left {
40                    display: flex;
41                    align-items: center;
42                    gap: 1rem;
43                }
44
45                .bam-header-icon {
46                    width: 44px;
47                    height: 44px;
48                    border-radius: 12px;
49                    background: hsl(var(--primary) / 0.15);
50                    color: hsl(var(--primary));
51                    display: flex;
52                    align-items: center;
53                    justify-content: center;
54                    flex-shrink: 0;
55                }
56
57                .bam-title-row {
58                    display: flex;
59                    align-items: center;
60                    gap: 0.75rem;
61                }
62
63                .bam-title {
64                    font-size: 1.25rem;
65                    font-weight: 800;
66                    color: hsl(var(--text-main));
67                    margin: 0;
68                }
69
70                .bam-live-badge {
71                    font-size: 0.7rem;
72                    font-weight: 700;
73                    padding: 0.15rem 0.5rem;
74                    border-radius: 12px;
75                    background: hsl(142 70% 45% / 0.15);
76                    color: hsl(142 70% 45%);
77                    border: 1px solid hsl(142 70% 45% / 0.3);
78                    text-transform: uppercase;
79                    letter-spacing: 0.04em;
80                }
81
82                .bam-subtitle {
83                    font-size: 0.82rem;
84                    color: hsl(var(--text-dim));
85                    margin: 0.2rem 0 0;
86                }
87
88                .bam-header-actions {
89                    display: flex;
90                    align-items: center;
91                    gap: 0.6rem;
92                }
93
94                .bam-close-btn {
95                    width: 36px;
96                    height: 36px;
97                    border-radius: 10px;
98                    border: 1px solid hsl(var(--border-color));
99                    background: hsl(var(--bg-secondary) / 0.6);
100                    color: hsl(var(--text-dim));
101                    display: flex;
102                    align-items: center;
103                    justify-content: center;
104                    cursor: pointer;
105                    transition: all 0.15s ease;
106                }
107                .bam-close-btn:hover {
108                    color: hsl(var(--text-main));
109                    background: hsl(var(--bg-hover, var(--bg-secondary)));
110                    transform: scale(1.05);
111                }
112
113                /* Toolbar */
114                .bam-toolbar {
115                    display: flex;
116                    align-items: center;
117                    justify-content: space-between;
118                    gap: 1rem;
119                    padding: 0.85rem 1.75rem;
120                    border-bottom: 1px solid hsl(var(--border-color));
121                    background: hsl(var(--bg-secondary) / 0.2);
122                    flex-wrap: wrap;
123                }
124
125                .bam-tabs {
126                    display: flex;
127                    align-items: center;
128                    gap: 0.35rem;
129                    overflow-x: auto;
130                    scrollbar-width: none;
131                }
132                .bam-tabs::-webkit-scrollbar { display: none; }
133
134                .bam-tab {
135                    display: inline-flex;
136                    align-items: center;
137                    gap: 0.4rem;
138                    padding: 0.4rem 0.75rem;
139                    border-radius: 8px;
140                    font-size: 0.8rem;
141                    font-weight: 600;
142                    background: transparent;
143                    color: hsl(var(--text-dim));
144                    border: 1px solid transparent;
145                    cursor: pointer;
146                    transition: all 0.15s ease;
147                    white-space: nowrap;
148                }
149                .bam-tab:hover {
150                    color: hsl(var(--text-main));
151                    background: hsl(var(--bg-secondary));
152                }
153                .bam-tab.active {
154                    color: hsl(var(--primary));
155                    background: hsl(var(--primary) / 0.12);
156                    border-color: hsl(var(--primary) / 0.3);
157                }
158
159                .bam-tab-count {
160                    font-size: 0.7rem;
161                    padding: 0.1rem 0.35rem;
162                    border-radius: 10px;
163                    background: hsl(var(--border-color));
164                    color: hsl(var(--text-main));
165                }
166                .bam-tab.active .bam-tab-count {
167                    background: hsl(var(--primary) / 0.25);
168                    color: hsl(var(--primary));
169                }
170
171                .bam-search-box {
172                    position: relative;
173                    display: flex;
174                    align-items: center;
175                    min-width: 290px;
176                }
177
178                .bam-search-icon {
179                    position: absolute;
180                    left: 0.95rem;
181                    top: 50%;
182                    transform: translateY(-50%);
183                    color: hsl(var(--text-dim));
184                    pointer-events: none;
185                    z-index: 2;
186                }
187
188                .bam-search-input {
189                    width: 100%;
190                    height: 38px;
191                    padding-left: 2.75rem !important;
192                    padding-right: 2.25rem !important;
193                    padding-top: 0.45rem;
194                    padding-bottom: 0.45rem;
195                    border-radius: 10px;
196                    border: 1px solid hsl(var(--border-color));
197                    background: hsl(var(--bg-card));
198                    color: hsl(var(--text-main));
199                    font-size: 0.82rem;
200                    outline: none;
201                    transition: all 0.2s ease;
202                }
203                .bam-search-input:focus {
204                    border-color: hsl(var(--primary));
205                    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.12);
206                }
207                .bam-search-input::placeholder {
208                    color: hsl(var(--text-dim));
209                }
210
211                .bam-search-clear {
212                    position: absolute;
213                    right: 0.65rem;
214                    background: none;
215                    border: none;
216                    color: hsl(var(--text-dim));
217                    cursor: pointer;
218                    display: flex;
219                    align-items: center;
220                }
221
222                /* Body */
223                .bam-body {
224                    flex: 1;
225                    overflow-y: auto;
226                    padding: 1.25rem 1.75rem;
227                }
228
229                .bam-timeline {
230                    display: flex;
231                    flex-direction: column;
232                    gap: 0.85rem;
233                }
234
235                .bam-log-card {
236                    padding: 1rem 1.15rem;
237                    border-radius: 14px;
238                    background: hsl(var(--bg-card));
239                    border: 1px solid hsl(var(--border-color));
240                    transition: border-color 0.15s ease;
241                }
242                .bam-log-card:hover {
243                    border-color: hsl(var(--border-color) / 1.5);
244                }
245
246                .bam-log-card.badge-create { border-left: 3px solid hsl(142 70% 45%); }
247                .bam-log-card.badge-update { border-left: 3px solid hsl(38 92% 50%); }
248                .bam-log-card.badge-payment { border-left: 3px solid hsl(var(--primary)); }
249                .bam-log-card.badge-delete { border-left: 3px solid hsl(var(--error)); }
250
251                .bam-log-main-row {
252                    display: flex;
253                    align-items: flex-start;
254                    gap: 1rem;
255                }
256
257                .bam-action-icon-box {
258                    width: 36px;
259                    height: 36px;
260                    border-radius: 10px;
261                    display: flex;
262                    align-items: center;
263                    justify-content: center;
264                    flex-shrink: 0;
265                    margin-top: 2px;
266                }
267                .bam-action-icon-box.badge-create { background: hsl(142 70% 45% / 0.14); color: hsl(142 70% 45%); }
268                .bam-action-icon-box.badge-update { background: hsl(38 92% 50% / 0.14); color: hsl(38 92% 50%); }
269                .bam-action-icon-box.badge-payment { background: hsl(var(--primary) / 0.14); color: hsl(var(--primary)); }
270                .bam-action-icon-box.badge-delete { background: hsl(var(--error) / 0.14); color: hsl(var(--error)); }
271
272                .bam-log-info {
273                    flex: 1;
274                    min-width: 0;
275                }
276
277                .bam-log-top-line {
278                    display: flex;
279                    align-items: center;
280                    gap: 0.5rem;
281                    flex-wrap: wrap;
282                }
283
284                .bam-action-pill {
285                    font-size: 0.68rem;
286                    font-weight: 700;
287                    padding: 0.15rem 0.45rem;
288                    border-radius: 6px;
289                    text-transform: uppercase;
290                    letter-spacing: 0.03em;
291                }
292                .bam-action-pill.badge-create { background: hsl(142 70% 45% / 0.15); color: hsl(142 70% 45%); }
293                .bam-action-pill.badge-update { background: hsl(38 92% 50% / 0.15); color: hsl(38 92% 50%); }
294                .bam-action-pill.badge-payment { background: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }
295                .bam-action-pill.badge-delete { background: hsl(var(--error) / 0.15); color: hsl(var(--error)); }
296
297                .bam-item-tag {
298                    font-size: 0.82rem;
299                    color: hsl(var(--text-main));
300                }
301
302                .bam-amount-badge {
303                    font-size: 0.82rem;
304                    font-weight: 800;
305                    color: hsl(var(--text-main));
306                    padding: 0.15rem 0.45rem;
307                    border-radius: 6px;
308                    background: hsl(var(--bg-secondary));
309                    border: 1px solid hsl(var(--border-color));
310                }
311
312                .bam-log-summary {
313                    font-size: 0.84rem;
314                    color: hsl(v
314ar(--text-main) / 0.9);
315                    margin: 0.35rem 0 0.5rem;
316                    line-height: 1.4;
317                }
318
319                .bam-meta-row {
320                    display: flex;
321                    align-items: center;
322                    gap: 1rem;
323                    flex-wrap: wrap;
324                }
325
326                .bam-actor-chip {
327                    display: inline-flex;
328                    align-items: center;
329                    gap: 0.35rem;
330                    font-size: 0.74rem;
331                    color: hsl(var(--text-dim));
332                }
333
334                .bam-actor-avatar {
335                    width: 20px;
336                    height: 20px;
337                    border-radius: 50%;
338                    background: hsl(var(--primary));
339                    color: #fff;
340                    font-size: 0.65rem;
341                    font-weight: 700;
342                    display: flex;
343                    align-items: center;
344                    justify-content: center;
345                }
346
347                .bam-actor-name {
348                    font-weight: 600;
349                    color: hsl(var(--text-main));
350                }
351
352                .bam-actor-role {
353                    font-size: 0.68rem;
354                    opacity: 0.8;
355                }
356
357                .bam-actor-email {
358                    font-size: 0.7rem;
359                    opacity: 0.65;
360                }
361
362                .bam-timestamp {
363                    display: inline-flex;
364                    align-items: center;
365                    gap: 0.3rem;
366                    font-size: 0.72rem;
367                    color: hsl(var(--text-dim));
368                }
369
370                .bam-diff-toggle-btn {
371                    padding: 0.35rem 0.65rem;
372                    border-radius: 8px;
373                    border: 1px solid hsl(var(--border-color));
374                    background: hsl(var(--bg-secondary) / 0.5);
375                    color: hsl(var(--text-dim));
376                    font-size: 0.74rem;
377                    font-weight: 600;
378                    cursor: pointer;
379                    transition: all 0.15s ease;
380                    white-space: nowrap;
381                }
382                .bam-diff-toggle-btn:hover {
383                    color: hsl(var(--text-main));
384                    border-color: hsl(var(--primary) / 0.4);
385                }
386
387                /* Diff Drawer */
388                .bam-diff-drawer {
389                    margin-top: 0.85rem;
390                    padding-top: 0.85rem;
391                    border-top: 1px dashed hsl(var(--border-color));
392                }
393
394                .bam-diff-grid {
395                    display: grid;
396                    grid-template-columns: 1fr 1fr;
397                    gap: 1rem;
398                }
399
400                .bam-diff-col {
401                    padding: 0.75rem;
402                    border-radius: 8px;
403                    background: hsl(var(--bg-secondary) / 0.4);
404                    border: 1px solid hsl(var(--border-color));
405                }
406                .bam-diff-col.before { border-color: hsl(var(--error) / 0.25); }
407                .bam-diff-col.after { border-color: hsl(142 70% 45% / 0.25); }
408
409                .bam-diff-header {
410                    display: block;
411                    font-size: 0.72rem;
412                    font-weight: 700;
413                    text-transform: uppercase;
414                    margin-bottom: 0.4rem;
415                    letter-spacing: 0.04em;
416                }
417                .bam-diff-col.before .bam-diff-header { color: hsl(var(--error)); }
418                .bam-diff-col.after .bam-diff-header { color: hsl(142 70% 45%); }
419
420                .bam-diff-content {
421                    display: flex;
422                    flex-direction: column;
423                    gap: 0.25rem;
424                }
425
426                .bam-diff-item {
427                    display: flex;
428                    align-items: center;
429                    justify-content: space-between;
430                    font-size: 0.75rem;
431                }
432                .bam-diff-key { color: hsl(var(--text-dim)); }
433                .bam-diff-val { font-weight: 600; color: hsl(var(--text-main)); }
434
435                /* Loading & Empty States */
436                .bam-loading-state, .bam-empty-state {
437                    padding: 4rem 2rem;
438                    text-align: center;
439                    display: flex;
440                    flex-direction: column;
441                    align-items: center;
442                    justify-content: center;
443                }
444
445                .bam-empty-icon {
446                    width: 64px;
447                    height: 64px;
448                    border-radius: 18px;
449                    background: hsl(var(--bg-secondary));
450                    color: hsl(var(--text-dim));
451                    display: flex;
452                    align-items: center;
453                    justify-content: center;
454                    margin-bottom: 1rem;
455                }
456
457                .bam-loading-state h4, .bam-empty-state h4 {
458                    font-size: 1.1rem;
459                    font-weight: 700;
460                    color: hsl(var(--text-main));
461                    margin: 0;
462                }
463
464                .bam-loading-state p, .bam-empty-state p {
465                    font-size: 0.85rem;
466                    color: hsl(var(--text-dim));
467                    max-width: 380px;
468                    margin: 0.4rem 0 0;
469                    line-height: 1.45;
470                }
471
472                /* Footer */
473                .bam-footer {
474                    display: flex;
475                    align-items: center;
476                    justify-content: space-between;
477                    padding: 1rem 1.75rem;
478                    border-top: 1px solid hsl(var(--border-color));
479                    background: hsl(var(--bg-secondary) / 0.4);
480                }
481
482                .bam-footer-info {
483                    display: flex;
484                    align-items: center;
485                    gap: 0.5rem;
486                    font-size: 0.75rem;
487                    color: hsl(var(--text-dim));
488                }
489
490                /* Standard button helpers */
491                .bam-btn-primary {
492                    display: inline-flex;
493                    align-items: center;
494                    gap: 0.4rem;
495                    padding: 0.5rem 0.9rem;
496                    border-radius: 10px;
497                    background: hsl(var(--primary));
498                    color: #fff;
499                    font-size: 0.82rem;
500                    font-weight: 600;
501                    border: none;
502                    cursor: pointer;
503                    transition: all 0.15s ease;
504                }
505                .bam-btn-primary:hover:not(:disabled) {
506                    opacity: 0.92;
507                    transform: translateY(-1px);
508                }
509                .bam-btn-primary:disabled { opacity: 0.5;
509 cursor: not-allowed; }
510
511                .bam-btn-outline {
512                    display: inline-flex;
513                    align-items: center;
514                    gap: 0.4rem;
515                    padding: 0.5rem 0.9rem;
516                    border-radius: 10px;
517                    background: hsl(var(--bg-secondary) / 0.6);
518                    border: 1px solid hsl(var(--border-color));
519                    color: hsl(var(--text-main));
520                    font-size: 0.82rem;
521                    font-weight: 600;
522                    cursor: pointer;
523                    transition: all 0.15s ease;
524                }
525                .bam-btn-outline:hover:not(:disabled) {
526                    background: hsl(var(--bg-hover, var(--bg-secondary)));
527                    border-color: hsl(var(--primary) / 0.4);
528                }
529
530                .bam-spin {
531                    animation: bamSpinAnim 1s linear infinite;
532                }
533
534                @keyframes bamSpinAnim {
535                    from { transform: rotate(0deg); }
536                    to { transform: rotate(360deg); }
537                }
538
539                @media (max-width: 640px) {
540                    .bam-modal-content {
541                        max-height: 94vh;
542                    }
543                    .bam-header {
544                        padding: 1rem 1.15rem;
545                    }
546                    .bam-toolbar {
547                        padding: 0.75rem 1.15rem;
548                    }
549                    .bam-body {
550                        padding: 1rem;
551                    }
552                    .bam-search-box {
553                        min-width: 100%;
554                    }
555                    .bam-diff-grid {
556                        grid-template-columns: 1fr;
557                    }
558                }
559            `})]})},Lt=({onClose:c,onSave:r,eventId:y,organizerId:E,editingExpense:s})=>{const{user:C}=ge(),[m,v]=x.useState(!1),{error:D,success:L}=fe(),i=Te(),[b,j]=x.useState(!1),[g,f]=x.useState(s?.status||"Pending"),[I,d]=x.useState(!1),[T,_]=x.useState({amount:"",date:new Date().toISOString().split("T")[0]}),[A,$]=x.useState(s?.paymentHistory||[]),n=(l=[])=>l.reduce((u,q)=>u+Number(q.amount),0);x.useEffect(()=>{if(A.length>0){const l=n(A),u=s?.amount||0;l>=u&&u>0?f("Paid"):l>0&&f("Partially Paid")}},[A,s]);const a=()=>{if(!T.amount||Number(T.amount)<=0){D("Please enter a valid payment amount");return}const l=n(A),q=Number(s?.amount||0)-l;if(Number(T.amount)>q){D(`Payment cannot exceed outstanding balance of ₦${q.toLocaleString()}`);return}const G=ie(C),H={id:`pay_${Date.now()}_${Math.random().toString(36).substring(2,6)}`,amount:Number(T.amount),date:T.date,timestamp:new Date().toISOString(),recordedBy:G,notes:"Balance Payment"},K=[...A,H];$(K),_({amount:"",date:new Date().toISOString().split("T")[0]}),L("Payment recorded locally. Click 'Update Expense' to save changes.")},P=async l=>{if(i)return;l.preventDefault(),v(!0);const u=new FormData(l.target),q=Number(u.get("amount"));let G=[...A];const H=ie(C);
559if(!s&&(g==="Paid"||g==="Partially Paid")){const O=Number(u.get("paidAmount"))||(g==="Paid"?q:0);O>0&&G.push({id:`pay_${Date.now()}_init`,amount:O,date:u.get("date"),timestamp:new Date().toISOString(),recordedBy:H,notes:"Initial Payment"})}const K=n(G),h={eventId:y,organizerId:E,item:u.get("item"),category:b?u.get("customCategory"):u.get("category"),amount:q,paidAmount:K,balance:q-K,status:g,date:u.get("date"),paymentHistory:G,updatedAt:new Date().toISOString()};try{if(s){h.lastModifiedBy=H;const O=be(C,"updated",`${H.name} updated expense "${h.item}"`,{before:{item:s.item,amount:s.amount,category:s.category,status:s.status},after:{item:h.item,amount:h.amount,category:h.category,status:h.status}});h.activityHistory=[...s.activityHistory||[],O];const{error:Y}=await B.update(U.BUDGET_ITEMS,s.id,h);if(Y)throw new Error(Y);await ae({eventId:y,organizerId:E,user:C,action:"update_expense",itemType:"expense",itemId:s.id,itemName:h.item,amount:h.amount,before:{item:s.item,amount:s.amount,category:s.category,status:s.status},after:{item:h.item,amount:h.amount,category:h.category,status:h.status}}),r({...h,id:s.id},!0)}else{h.createdAt=new Date().toISOString(),h.createdBy=H;const O=be(C,"created",`${H.name} created expense "${h.item}" for ₦${h.amount.toLocaleString()}`);h.activityHistory=[O];const{id:Y,error:Q}=await B.add(U.BUDGET_ITEMS,h);if(Q)throw new Error(Q);await ae({eventId:y,organizerId:E,user:C,action:"create_expense",itemType:"expense",itemId:Y,itemName:h.item,amount:h.amount,after:{item:h.item,category:h.category,amount:h.amount,status:h.status}}),r({...h,id:Y},!1)}}catch(O){console.error("Error saving expense:",O),D("Failed to save expense")}finally{v(!1)}},R=n(A),S=(s?.amount||0)-R;return e.jsx("div",{className:"modal-overlay",onClick:c,children:e.jsxs("div",{className:"expense-modal-content",onClick:l=>l.stopPropagation(),children:[e.jsxs("div",{className:"expense-modal-header",children:[e.jsxs("div",{className:"expense-modal-header-content",children:[e.jsx("div",{className:"expense-modal-icon",children:e.jsx(xe,{size:24})}),e.jsxs("div",{children:[e.jsx("h2",{className:"expense-modal-title",children:s?"Edit Expense":"Add New Expense"}),e.jsx("p",{className:"expense-modal-subtitle",children:s?"Update expense details and manage payments":"Record a new expense for your event"})]})]}),e.jsx("button",{className:"expense-modal-close",onClick:c,children:e.jsx(ee,{size:20})})]}),e.jsxs("form",{onSubmit:P,className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"label",children:"Expense Item"}),e.jsx("input",{type:"text",name:"item",required:!0,className:"form-input",placeholder:"e.g. Venue Rental",defaultValue:s?.item})]}),e.jsxs("div",{className:"form-row-2",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"label",children:"Category"}),b?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",name:"customCategory",required:!0,className:"form-input",placeholder:"Enter category name",autoFocus:!0}),e.jsx("button",{type:"button",className:"btn-icon border border-border",onClick:()=>j(!1),children:e.jsx(ee,{size:16})})]}):e.jsxs("select",{name:"category",required:!0,className:"form-input",defaultValue:s?.category||"Venue",onChange:l=>l.target.value==="custom"&&j(!0),children:[e.jsx("option",{value:"Venue",children:"Venue"}),e.jsx("option",{value:"Marketing",children:"Marketing"}),e.jsx("option",{value:"Catering",children:"Catering"}),e.jsx("option",{value:"Speakers",children:"Speakers"}),e.jsx("option",{value:"Production",children:"Production"}),e.jsx("option",{value:"Logistics",children:"Logistics"}),e.jsx("option",{value:"Technology",children:"Technology"}),e.jsx("option",{value:"Other",children:"Other"}),e.jsx("option",{value:"custom",className:"font-bold text-primary",children:"+ Create New Category"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"label",children:"Total Amount (₦)"}),e.jsx("input",{type:"number",name:"amount",required:!0,className:"form-input",placeholder:"0.00",defaultValue:s?.amount,readOnly:A.length>0,title:A.length>0?"Cannot edit amount with payment history":""})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-5",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"label",children:"Status"}),e.jsxs("select",{name:"status",required:!0,className:"form-input",value:g,onChange:l=>f(l.target.value),disabled:A.length>0,children:[e.jsx("option",{value:"Pending",children:"Pending"}),e.jsx("option",{value:"Partially Paid",children:"Partially Paid"}),e.jsx("option",{value:"Paid",children:"Paid (Fully)"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"label",children:"Original Date"}),e.jsx("input",{type:"date",name:"date",required:!0,className:"form-input",defaultValue:s?.date?new Date(s.date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0]})]})]}
559),!s&&g==="Partially Paid"&&e.jsxs("div",{className:"form-group mt-4 p-4 bg-bg-dark border border-border rounded-lg anim-scale-in",children:[e.jsx("label",{className:"label text-primary",children:"Initial Payment Amount (₦)"}),e.jsx("input",{type:"number",name:"paidAmount",required:!0,min:"1",className:"form-input border-primary",placeholder:"e.g. 50000"}),e.jsx("span",{className:"text-xs text-dim mt-1 block",children:"Enter the initial deposit. The balance will be tracked automatically."})]}),s&&e.jsxs("div",{className:"payment-history-section",children:[e.jsxs("h3",{className:"payment-history-title",children:[e.jsx(xe,{size:18}),"Payment History"]}),e.jsxs("div",{className:"payment-stats-grid",children:[e.jsxs("div",{className:"payment-stat-card",children:[e.jsx("div",{className:"payment-stat-label",children:"Total Paid"}),e.jsxs("div",{className:"payment-stat-value",style:{color:"hsl(var(--success))"},children:["₦",R.toLocaleString()]})]}),e.jsxs("div",{className:"payment-stat-card",children:[e.jsx("div",{className:"payment-stat-label",children:"Balance"}),e.jsxs("div",{className:"payment-stat-value",style:{color:"hsl(var(--error))"},children:["₦",S.toLocaleString()]})]}),e.jsxs("div",{className:"payment-stat-card",children:[e.jsx("div",{className:"payment-stat-label",children:"Payments"}),e.jsx("div",{className:"payment-stat-value",children:A.length})]})]}),A.length>0?e.jsx("div",{className:"payment-timeline",children:A.map((l,u)=>e.jsxs("div",{className:"payment-record",children:[e.jsxs("div",{className:"payment-record-info",children:[e.jsxs("span",{className:"payment-record-amount",children:["₦",Number(l.amount).toLocaleString()]}),e.jsx("span",{className:"payment-record-date",children:new Date(l.date).toLocaleDateString()})]}),e.jsx("span",{className:"payment-record-badge",children:l.notes||"Payment"})]},u))}):e.jsx("div",{className:"payment-empty",children:"No payments recorded yet"}),S>0&&e.jsxs("div",{className:"payment-new-section",children:[e.jsx("h4",{className:"payment-new-title",children:"Record Balance Payment"}),e.jsxs("div",{className:"payment-new-form",children:[e.jsxs("div",{className:"payment-new-field",children:[e.jsx("label",{className:"label",children:"Amount"}),e.jsx("input",{type:"number",className:"form-input",placeholder:"0.00",value:T.amount,onChange:l=>_({...T,amount:l.target.value})})]}),e.jsxs("div",{className:"payment-new-field",children:[e.jsx("label",{className:"label",children:"Date"}),e.jsx("input",{type:"date",className:"form-input",value:T.date,onChange:l=>_({...T,date:l.target.value})})]}),e.jsx("button",{type:"button",className:"btn btn-primary payment-add-btn",onClick:a,children:e.jsx(Z,{size:18})})]})]})]}),e.jsxs("div",{className:"modal-footer mt-6 flex justify-end gap-3",children:[e.jsx("button",{type:"button",className:"btn btn-outline",onClick:c,children:"Cancel"}),e.jsx("button",{type:"submit",className:"btn btn-primary",disabled:m,children:m?"Saving...":s?"Update Expense":"Add Expense"})]})]})]})})},It=({onClose:c,onSave:r,eventId:y,organizerId:E,editingRevenue:s})=>{const{user:C}=ge(),m=Te(),{error:v}=fe(),[D,L]=x.useState(!1),[i,b]=x.useState(!1),j=async g=>{if(m)return;g.preventDefault(),L(!0);const f=new FormData(g.target),I=ie(C),d={eventId:y,organizerId:E,source:i?f.get("customSource"):f.get("source"),type:f.get("type"),amount:Number(f.get("amount")),status:f.get("status"),date:f.get("date"),updatedAt:new Date().toISOString()};try{if(s){d.lastModifiedBy=I;const T=be(C,"updated",`${I.name} updated revenue source "${d.source}"`,{before:{source:s.source,amount:s.amount,type:s.type,status:s.status},after:{source:d.source,amount:d.amount,type:d.type,status:d.status}});d.activityHistory=[...s.activityHistory||[],T];const{error:_}=await B.update(U.REVENUE_ITEMS,s.id,d);if(_)throw new Error(_);await ae({eventId:y,organizerId:E,user:C,action:"update_revenue",itemType:"revenue",itemId:s.id,itemName:d.source,amount:d.amount,before:{source:s.source,amount:s.amount,type:s.type,status:s.status},after:{source:d.source,amount:d.amount,type:d.type,status:d.status}}),r({...d,id:s.id},!0)}else{d.createdAt=new Date().toISOString(),d.createdBy=I;const T=be(C,"created",`${I.name} created revenue source "${d.source}
559" for ₦${d.amount.toLocaleString()}`);d.activityHistory=[T];const{id:_,error:A}=await B.add(U.REVENUE_ITEMS,d);if(A)throw new Error(A);await ae({eventId:y,organizerId:E,user:C,action:"create_revenue",itemType:"revenue",itemId:_,itemName:d.source,amount:d.amount,after:{source:d.source,amount:d.amount,type:d.type,status:d.status}}),r({...d,id:_},!1)}}catch(T){console.error("Error saving revenue:",T),v("Failed to save revenue")}finally{L(!1)}};return e.jsx("div",{className:"modal-overlay",onClick:c,children:e.jsxs("div",{className:"modal-content neon-card anim-scale-in",onClick:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{className:"text-xl font-bold",children:s?"Edit Revenue Source":"Add Revenue Source"}),e.jsx("button",{className:"btn-icon",onClick:c,children:e.jsx(ee,{size:24})})]}),e.jsxs("form",{onSubmit:j,className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"label",children:"Revenue Source"}),i?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",name:"customSource",required:!0,className:"form-input",placeholder:"Enter source name",autoFocus:!0}),e.jsx("button",{type:"button",className:"btn-icon border border-border",onClick:()=>b(!1),children:e.jsx(ee,{size:16})})]}):e.jsxs("select",{name:"source",required:!0,className:"form-input",defaultValue:s?.source||"Ticket Sales",onChange:g=>{g.target.value==="custom"&&b(!0)},children:[e.jsx("option",{value:"Ticket Sales",children:"Ticket Sales"}),e.jsx("option",{value:"Sponsorship",children:"Sponsorship"}),e.jsx("option",{value:"Merchandise",children:"Merchandise"}),e.jsx("option",{value:"Donations",children:"Donations"}),e.jsx("option",{value:"Grants",children:"Grants"}),e.jsx("option",{value:"Vendor Fees",children:"Vendor Fees"}),e.jsx("option",{value:"custom",className:"font-bold text-primary",children:"+ Custom Source"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-5",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"label",children:"Type"}),e.jsxs("select",{name:"type",required:!0,className:"form-input",defaultValue:s?.type||"Target",children:[e.jsx("option",{value:"Target",children:"Target (Projected)"}),e.jsx("option",{value:"Actual",children:"Actual (Received)"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"label",children:"Amount (₦)"}),e.jsx("input",{type:"number",name:"amount",required:!0,className:"form-input",placeholder:"0.00",defaultValue:s?.amount})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-5",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"label",children:"Status"}),e.jsxs("select",{name:"status",required:!0,className:"form-input",defaultValue:s?.status||"Received",children:[e.jsx("option",{value:"Received",children:"Received"}),e.jsx("option",{value:"Pending",children:"Pending"}),e.jsx("option",{value:"Pledged",children:"Pledged"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"label",children:"Date"}),e.jsx("input",{type:"date",name:"date",required:!0,className:"form-input",defaultValue:s?.date?new Date(s.date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0]})]})]}),e.jsxs("div",{className:"modal-footer mt-6 flex justify-end gap-3",children:[e.jsx("button",{type:"button",className:"btn btn-outline",onClick:c,children:"Cancel"}),e.jsx("button",{type:"submit",className:"btn btn-primary",disabled:D,children:D?"Saving...":s?"Update Revenue":"Add Revenue"})]})]})]})})},Gt=()=>{const{eventId:c}=ft(),{user:r}=ge(),[y,E]=x.useState([]),[s,C]=x.useState(c||null);x.useEffect(()=>{(async()=>{if(!r)return;const N=r.role==="team_member"?r.organizerId:r.uid,{data:k}=await B.getAll(U.EVENTS,[{field:"organizerId",operator:"==",value:N}]);k&&(E(k),!c&&k.length>0&&!s&&C(k[0].id))})()},[r,c]),x.useEffect(()=>{c&&C(c)},[c]);const m=s,v=y.find(t=>t.id===m),D=v?.title||"Select Event",{success:L,error:i}=fe(),b=Te(),[j,g]=x.useState("expenses"),[f,I]=x.useState(""),[d,T]=x.useState([]),[_,A]=x.useState([]),[$,n]=x.useState(!0),[a,P]=x.use
559State({spent:0,revenue:0,totalBudget:0}),[R,S]=x.useState(!1),[l,u]=x.useState(!1),[q,G]=x.useState(!1),[H,K]=x.useState(!1),[h,O]=x.useState({id:null,type:null,item:null,position:{top:0,right:0}}),[Y,Q]=x.useState(null),[ye,p]=x.useState(null),[o,W]=x.useState(!1);x.useEffect(()=>{if(!h.id)return;const t=()=>{O({id:null,type:null,item:null,position:{top:0,right:0}})};return window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[h.id]);const V=(t,N,k)=>{if(t.stopPropagation(),h.id===N.id){O({id:null,type:null,item:null,position:{top:0,right:0}});return}const F=t.currentTarget.getBoundingClientRect(),X=F.bottom+120>window.innerHeight;O({id:N.id,type:k,item:N,position:{top:X?Math.max(10,F.top-88):F.bottom+6,right:Math.max(10,window.innerWidth-F.right)}})},M=()=>{O({id:null,type:null,item:null,position:{top:0,right:0}})},J=r?.role?.startsWith("organizer")||r?.role==="admin",We=r?.role==="team_member"&&!!(r?.canManageFinance||r?.permissions?.finance),Ve=J||We,Ge=t=>{Q(t),S(!0),M()},He=t=>{p(t),G(!0),M()},Ye=async t=>{if(b){i("Renew your plan to make changes.");return}if(!await Le(`Are you sure you want to delete expense "${t.item}"?`))return;const N=r?.role==="team_member"?r.organizerId:r?.uid;await ae({eventId:m||t.eventId,organizerId:N,user:r,action:"delete_expense",itemType:"expense",itemId:t.id,itemName:t.item,amount:t.amount,before:{item:t.item,category:t.category,amount:t.amount,paidAmount:t.paidAmount,balance:t.balance,status:t.status,date:t.date,paymentHistory:t.paymentHistory||[]}});const{error:k}=await B.delete(U.BUDGET_ITEMS,t.id);k?i("Failed to delete expense"):(T(F=>F.filter(X=>X.id!==t.id)),L("Expense deleted successfully")),setActiveActionId(null)},qe=async t=>{if(b){i("Renew your plan to make changes.");return}if(!await Le(`Delete revenue source "${t.source}"?`))return;const N=r?.role==="team_member"?r.organizerId:r?.uid;await ae({eventId:m||t.eventId,organizerId:N,user:r,action:"delete_revenue",itemType:"revenue",itemId:t.id,itemName:t.source,amount:t.amount,before:{source:t.source,type:t.type,amount:t.amount,status:t.status,date:t.date,target:t.target}});const{error:k}=await B.delete(U.REVENUE_ITEMS,t.id);k?i("Failed to delete"):(se(),L("Revenue source deleted")),setActiveActionId(null)};x.useEffect(()=>{r&&m&&se()},[m,r]);const se=async()=>{if(r){n(!0);try{const t=r?.role==="team_member"?r.organizerId:r?.uid,N=[{field:"eventId",operator:"==",value:m},{field:"organizerId",operator:"==",value:t}],k=[{field:"eventId",operator:"==",value:m}],[F,X,re,Ke,Je,Ze,et,tt]=await Promise.all([B.getAll(U.BUDGET_ITEMS,N),B.getAll(U.TICKETS,k).catch(()=>({data:[]})),B.getAll(U.ORDERS,[{field:"shopId",operator:"==",value:m}]).catch(()=>({data:[]})),B.getAll(U.VOTES,k).catch(()=>({data:[]})),B.getAll(U.NOMINEES,k).catch(()=>({data:[]})),B.getAll(U.SPONSORS,N).catch(()=>({data:[]})),B.getAll(U.SPONSOR_TIERS,N).catch(()=>({data:[]})),B.getAll(U.REVENUE_ITEMS,N).catch(()=>({data:[]}))]),Ne=F?.data||[];T(Ne);const at=X?.data||[],st=["valid","confirmed","paid","checked-in"],ze=at.filter(z=>st.includes(z.status)&&z.paymentStatus!=="failed"&&z.paymentStatus!=="refunded").reduce((z,w)=>{const ne=w.price!==void 0&&w.price!==null&&w.price!==""?Number(w.price):Number(w.amount||0);return z+(isNaN(ne)?0:ne)},0),rt={id:"ticket-sales-virtual",source:"Ticket Sales",type:"Tickets",amount:ze,status:"In Progress",date:"Ongoing"},nt=re?.data||[],it=["paid","completed","fulfilled","confirmed"],De=nt.filter(z=>it.includes(z.status)).reduce((z,w)=>{const ne=Number(w.totalAmount||w.subtotal||0);return z+(isNaN(ne)?0:ne)},0),lt={id:"shop-sales-virtual",source:"Shop / Merchandise",type:"Shop",amount:De,status:"In Progress",date:"Ongoing"},ot=Ke?.data||[],ct=Je?.data||[],dt=ot.filter(z=>z.status!=="pending_payment"&&z.status!=="failed").reduce((z,w)=>z+(Number(w.voteSubtotal||w.totalAmount)||0),0),mt=ct.reduce((z,w)=>z+(w.isPaidRegistration&&w.paymentVerified&&Number(w.registrationFee)||0),0),Se=dt+mt,Ee=Se>
5590?{id:"competition-sales-virtual",source:"Competition & Voting",type:"Voting",amount:Se,status:"In Progress",date:"Ongoing"}:null,ut=Ze?.data||[],ht=(et?.data||[]).reduce((z,w)=>(z[w.id]=Number(w.price)||0,z),{}),Ae=ut.reduce((z,w)=>z+(ht[w.tierId]||Number(w.amount||w.customAmount||0)),0),pt={id:"sponsorship-virtual",source:"Sponsorships",type:"Sponsors",amount:Ae,status:"In Progress",date:"Ongoing"},Pe=tt?.data||[],xt=Pe.filter(z=>z.status==="Received").reduce((z,w)=>z+(Number(w.amount)||0),0),Re=[rt,lt,pt];Ee&&Re.push(Ee),A([...Re,...Pe]);const Fe=Ne.reduce((z,w)=>z+(Number(w.amount)||0),0),bt=Ne.reduce((z,w)=>z+(Number(w.paidAmount||(w.status==="Paid"?w.amount:0))||0),0),gt=ze+De+Se+Ae+xt;P({spent:Fe,paidSpent:bt,revenue:gt,totalBudget:Fe})}catch(t){console.error("Error fetching budget data:",t),i("Failed to load budget data")}finally{n(!1)}}},Qe=(t,N)=>{N?(T(k=>k.map(F=>F.id===t.id?t:F)),L("Expense updated successfully")):(T(k=>[...k,t]),L("Expense added successfully")),S(!1),Q(null),se()},Xe=(t,N)=>{N?(se(),L("Revenue updated")):(se(),L("Revenue source added")),G(!1),p(null)},ve=d.filter(t=>t.item?.toLowerCase().includes(f.toLowerCase())||t.category?.toLowerCase().includes(f.toLowerCase())),je=_.filter(t=>t.source?.toLowerCase().includes(f.toLowerCase()));return r&&!Ve?e.jsx("div",{className:"budget-container anim-fade-in budget-restricted-wrapper",children:e.jsxs("div",{className:"budget-restricted-card",children:[e.jsx("div",{className:"budget-restricted-icon-box",children:e.jsx(Ue,{size:32})}),e.jsx("h2",{className:"budget-restricted-title",children:"Restricted Financial Access"}),e.jsxs("p",{className:"budget-restricted-desc",children:["Budget & Finance management is strictly limited to the Event Organizer and authorized ",e.jsx("strong",{children:"Finance Staff"}),". If you require clearance to view or manage event budgets, please contact your workspace organizer."]}),e.jsx(yt,{to:"/organizer/dashboard",className:"btn btn-primary budget-restricted-btn",children:"Return to Dashboard"})]})}):e.jsxs("div",{className:"budget-container anim-fade-in",children:[e.jsxs("div",{className:"page-header-premium",children:[e.jsxs("div",{children:[!c&&e.jsxs("div",{className:"event-selector-wrapper",children:[e.jsxs("button",{className:"event-selector-button",onClick:()=>W(!o),children:[e.jsx("div",{className:"event-selector-icon",children:e.jsx(Oe,{size:14})}),e.jsx("span",{className:"event-selector-text",children:D}),e.jsx(wt,{size:14,className:`event-selector-chevron ${o?"open":""}`})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"event-selector-backdrop",onClick:()=>W(!1)}),e.jsxs("div",{className:"event-selector-dropdown",children:[e.jsx("div",{className:"event-selector-header",children:e.jsx("p",{children:"SELECT EVENT"})}),e.jsxs("div",{className:"event-selector-list",children:[y.map(t=>e.jsxs("button",{className:`event-selector-item ${m===t.id?"active":""}`,onClick:()=>{C(t.id),W(!1)},children:[e.jsx("div",{className:"event-selector-dot"}),e.jsx("span",{className:"event-selector-item-text",children:t.title})]},t.id)),y.length===0&&e.jsx("div",{className:"text-center py-4 text-dim text-sm",children:"No events found"})]})]})]})]}),e.jsxs("h1",{className:"title-premium",children:[e.jsx(Ct,{size:32,className:"title-icon-premium"}),"Budget & Finance"]}),e.jsx("p",{className:"subtitle-premium",children:c?e.jsxs("span",{children:["Managing finances for ",e.jsx("span",{className:"font-semibold",style:{color:"hsl(var(--text-main))"},children:D})]}):"Track expenses, revenue, and overall event profitability across your events."})]}),e.jsxs("div",{className:"header-actions-premium",children:[J&&e.jsxs("button",{className:"btn-premium-action",onClick:()=>K(!0),title:"View comprehensive audit logs for all budget activities",children:[e.jsx(ue,{size:18}),e.jsx("span",{children:"Audit Trail"})]}),e.jsxs("button",{className:"btn-premium-action",onClick:()=>u(!0),children:[e.jsx(ke,{size:20}),e.jsx("span",{children:"Export PDF"})]}),j==="expenses"?e.jsxs("button",{className:"btn-premium-action primary",disabled:b,onClick:()=>
559{if(!m){i("Please select an event first");return}Q(null),S(!0)},children:[e.jsx(Z,{size:20}),e.jsx("span",{children:"Add Expense"})]}):e.jsxs("button",{className:"btn-premium-action primary",disabled:b,onClick:()=>{if(!m){i("Please select an event first");return}p(null),G(!0)},children:[e.jsx(Z,{size:20}),e.jsx("span",{children:"Add Revenue Source"})]})]})]}),e.jsxs("div",{className:"stats-grid",children:[e.jsxs("div",{className:"stat-card-premium",children:[e.jsxs("div",{className:"stat-header",children:[e.jsx("div",{className:"stat-icon-wrapper success",children:e.jsx(we,{size:20})}),e.jsx("span",{className:"stat-label",children:"TOTAL REVENUE"})]}),e.jsxs("div",{className:"stat-value",children:["₦",a.revenue.toLocaleString()]}),e.jsxs("div",{className:"stat-trend success",children:[e.jsx(we,{size:14}),e.jsx("span",{children:"Live sales & income"})]})]}),e.jsxs("div",{className:"stat-card-premium",children:[e.jsxs("div",{className:"stat-header",children:[e.jsx("div",{className:"stat-icon-wrapper error",children:e.jsx(Tt,{size:20})}),e.jsx("span",{className:"stat-label",children:"ACTUAL SPENT"})]}),e.jsxs("div",{className:"stat-value",children:["₦",a.spent.toLocaleString()]}),e.jsx("div",{className:"stat-trend neutral",children:e.jsx("span",{children:a.paidSpent>0?`₦${a.paidSpent.toLocaleString()} paid out`:`${d.length} expense item${d.length!==1?"s":""}`})})]}),e.jsxs("div",{className:"stat-card-premium",children:[e.jsxs("div",{className:"stat-header",children:[e.jsx("div",{className:"stat-icon-wrapper primary",children:e.jsx(he,{size:20})}),e.jsx("span",{className:"stat-label",children:"NET PROFIT"})]}),e.jsxs("div",{className:"stat-value",style:{color:a.revenue-a.spent>=0?"hsl(var(--text-main))":"hsl(var(--error))"},children:[a.revenue-a.spent<0?"-":"","₦",Math.abs(a.revenue-a.spent).toLocaleString()]}),e.jsx("div",{className:`stat-trend ${a.revenue>=a.spent?"info":"error"}`,children:e.jsxs("span",{children:[a.revenue>0?((a.revenue-a.spent)/a.revenue*100).toFixed(1):0,"% margin"]})})]}),e.jsxs("div",{className:"stat-card-premium",children:[e.jsxs("div",{className:"stat-header",children:[e.jsx("div",{className:"stat-icon-wrapper warning",children:e.jsx(Oe,{size:20})}),e.jsx("span",{className:"stat-label",children:"PROJECTIONS"})]}),e.jsxs("div",{className:"stat-value",children:["₦",(a.revenue*1.2).toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsx("div",{className:"stat-trend neutral",children:e.jsx("span",{children:"based on current trends"})})]})]}),e.jsxs("div",{className:"budget-toolbar",children:[e.jsxs("div",{className:"tabs-container",children:[e.jsx("button",{className:`tab-btn-premium ${j==="expenses"?"active":""}`,onClick:()=>g("expenses"),children:"Expenses"}),e.jsx("button",{className:`tab-btn-premium ${j==="revenue"?"active":""}`,onClick:()=>g("revenue"),children:"Revenue Streams"})]}),e.jsxs("div",{className:"search-input-wrapper",children:[e.jsx(Be,{size:16,className:"search-icon-premium"}),e.jsx("input",{type:"text",placeholder:"Search entries...",className:"search-input-premium",value:f,onChange:t=>I(t.target.value)})]})]}),j==="expenses"?e.jsx(e.Fragment,{children:$?e.jsxs("div",{className:"empty-state-card-premium",children:[e.jsx("div",{className:"empty-state-icon-premium",children:e.jsx(xe,{size:48})}),e.jsx("h3",{className:"empty-state-title-premium",children:"Track Your Event Expenses"}),e.jsx("p",{className:"empty-state-text-premium",children:"Get complete visibility of your event spending. Monitor costs, track payments, and maintain a healthy budget."}),e.jsxs("div",{className:"empty-state-features",children:[e.jsx("span",{className:"empty-state-badge",children:"📊 Real-time Tracking"}),e.jsx("span",{className:"empty-state-badge",children:"💰 Payment History"}),e.jsx("span",{className:"empty-state-badge",children:"📈 Budget Insights"})]}),e.jsxs("button",{className:"btn-premium-action primary",onClick:()=>{if(!m){i("Please select an event first");return}Q(null),S(!0)},children:[e.jsx(Z,{size:20}),e.jsx("span",{children:"Add First Expense"})]})]}):ve.length===0?e.jsxs("div",{className:"empty-state-card",children:[e.jsx("div",{className:"empty-state-icon",children:e.jsx(xe,{size:48})}),e.jsx("h3",{className:"empty-state-title",children:"No Expenses Recorded Yet"}),e.jsx("p",{className:"empty-state-text",children:"Start tracking your event expenses by adding your first entry."}),e.jsxs("button",{className:"btn-premium-action primary",onClick:()=>
559{if(!m){i("Please select an event first");return}Q(null),S(!0)},children:[e.jsx(Z,{size:20}),e.jsx("span",{children:"Add First Expense"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"content-card-premium budget-desktop-view",children:e.jsx("div",{className:"table-responsive",children:e.jsxs("table",{className:"premium-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"EXPENSE ITEM"}),e.jsx("th",{children:"CATEGORY"}),e.jsx("th",{children:"AMOUNT"}),e.jsx("th",{children:"PAID / BALANCE"}),e.jsx("th",{children:"STATUS"}),e.jsx("th",{children:"DATE"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:ve.map(t=>e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:"font-medium",style:{color:"hsl(var(--text-main))"},children:t.item}),e.jsx("td",{children:e.jsx("span",{className:"badge badge-neutral",children:t.category})}),e.jsxs("td",{className:"font-bold",children:["₦",Number(t.amount).toLocaleString()]}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col text-xs",children:t.status==="Paid"||t.paidAmount>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-success",children:["Paid: ₦",(t.paidAmount||Number(t.amount)).toLocaleString()]}),t.balance>0&&e.jsxs("span",{className:"text-error",children:["Bal: ₦",Number(t.balance).toLocaleString()]})]}):e.jsx("span",{children:"—"})})}),e.jsx("td",{children:e.jsx("span",{className:`badge ${t.status==="Paid"?"badge-success":t.status==="Partially Paid"?"badge-warning":"badge-neutral"}`,children:t.status})}),e.jsx("td",{className:"text-dim",children:new Date(t.date).toLocaleDateString()}),e.jsx("td",{className:"text-right relative",children:e.jsx("button",{className:"btn-icon-sm opacity-0 group-hover:opacity-100 transition-opacity",onClick:N=>V(N,t,"expense"),children:e.jsx(le,{size:16})})})]},t.id))})]})})}),e.jsx("div",{className:"budget-mobile-view budget-mobile-cards",children:ve.map(t=>{const N=Number(t.amount)||0,k=t.status==="Paid"?N:Number(t.paidAmount)||0,F=t.balance!==void 0?Number(t.balance):Math.max(0,N-k),X=N>0?Math.min(100,Math.round(k/N*100)):0;return e.jsxs("div",{className:"budget-mobile-card",children:[e.jsxs("div",{className:"mobile-card-top",children:[e.jsxs("div",{className:"mobile-card-title-group",children:[e.jsx("h4",{className:"mobile-card-title",children:t.item}),e.jsxs("div",{className:"mobile-card-tags",children:[e.jsx("span",{className:"badge badge-neutral",children:t.category}),e.jsx("span",{className:`badge ${t.status==="Paid"?"badge-success":t.status==="Partially Paid"?"badge-warning":"badge-neutral"}`,children:t.status})]})]}),e.jsx("div",{className:"mobile-card-actions",children:e.jsx("button",{className:"btn-icon-sm",onClick:re=>V(re,t,"expense"),children:e.jsx(le,{size:18})})})]}),e.jsxs("div",{className:"mobile-card-stats-grid",children:[e.jsxs("div",{className:"mobile-stat-box",children:[e.jsx("span",{className:"mobile-stat-label",children:"Total Amount"}),e.jsxs("span",{className:"mobile-stat-val",children:["₦",N.toLocaleString()]})]}),e.jsxs("div",{className:"mobile-stat-box",children:[e.jsx("span",{className:"mobile-stat-label",children:"Paid / Balance"}),k>0||t.status==="Paid"?e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"mobile-stat-val text-success",children:["₦",k.toLocaleString()]}),F>0&&e.jsxs("span",{className:"mobile-stat-sub text-error",children:["Bal: ₦",F.toLocaleString()]})]}):e.jsx("span",{className:"mobile-stat-val text-dim",children:"₦0 (Pending)"})]})]}),N>0&&(k>0||t.status==="Paid")&&e.jsxs("div",{className:"mobile-card-progress-wrap",children:[e.jsx("div",{className:"mobile-card-progress-track",children:e.jsx("div",{className:`mobile-card-progress-bar ${t.status==="Paid"?"bg-success":"bg-warning"}`,style:{width:`${X}%`}})}),e.jsxs("div",{className:"mobile-card-progress-labels",children:[e.jsxs("span",{children:[X,"% settled"]}),t.paymentHistory?.length>0&&e.jsxs("span",{children:[t.paymentHistory.length," ",t.paymentHistory.length===1?"payment":"payments"]})]})]}),e.jsxs("div",{className:"mobile-card-footer",children:[e.jsxs("div",{className:"mobile-card-date",children:[e.jsx(Ce,{size:13}),e.jsx("span",{children:new Date(t.date).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})})]}),t.notes&&e.jsx("span",{className:"mobile-card-notes truncate",title:t.notes,children:t.notes})]})]},t.id)})})]})}):e.jsx(e.Fragment,{children:$?e.jsxs("div",{className:"empty-state-card-premium",children:[e.jsx("div",{className:"empty-state-icon-premium",children:e.jsx(he,{size:48})}),e.jsx("h3",{className:"empty-state-title-premium",children:"Manage Your Revenue Streams"}),e.jsx("p",{className:"empty-state-text-premium",children:"Track all income sources for your event. From ticket sales to sponsorships, keep every revenue stream organized."}),e.jsxs("div",{className:"empty-state-features",children:[e.jsx("span",{className:"empty-state-badge",children:"🎫 Ticket Sales"}),e.jsx("span",{className:"empty-state-badge",children:"🛍️ Shop / Merchandise"}),e.jsx("span",{className:"empty-state-badge",children:"🤝 Sponsorships"}),e.jsx("span",{className:"empty-state-badge",children:"📊 Revenue Analytics"})]}),e.jsxs("button",{className:"btn-premium-action primary",onClick:()=>
559{if(!m){i("Please select an event first");return}p(null),G(!0)},children:[e.jsx(Z,{size:20}),e.jsx("span",{children:"Add Revenue Source"})]})]}):je.length===0?e.jsxs("div",{className:"empty-state-card",children:[e.jsx("div",{className:"empty-state-icon",children:e.jsx(he,{size:48})}),e.jsx("h3",{className:"empty-state-title",children:"No Revenue Sources Found"}),e.jsx("p",{className:"empty-state-text",children:"Track your event income sources including ticket sales, shop merchandise, sponsorships, and other revenue streams."}),e.jsxs("button",{className:"btn-premium-action primary",onClick:()=>{if(!m){i("Please select an event first");return}p(null),G(!0)},children:[e.jsx(Z,{size:20}),e.jsx("span",{children:"Add Revenue Source"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"content-card-premium budget-desktop-view",children:e.jsx("div",{className:"table-responsive",children:e.jsxs("table",{className:"premium-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"SOURCE"}),e.jsx("th",{children:"TYPE"}),e.jsx("th",{children:"AMOUNT"}),e.jsx("th",{children:"TARGET / PROGRESS"}),e.jsx("th",{children:"STATUS"}),e.jsx("th",{children:"DATE"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:je.map(t=>{const N=t.id?.includes("virtual");return e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:"font-medium",style:{color:"hsl(var(--text-main))"},children:t.source}),e.jsx("td",{children:e.jsx("span",{className:"badge badge-neutral",children:t.type})}),e.jsxs("td",{className:"font-bold text-success",children:["₦",Number(t.amount).toLocaleString()]}),e.jsx("td",{children:!N&&t.target?e.jsxs("div",{className:"flex flex-col text-xs",children:[e.jsxs("span",{className:"text-success",children:["Target: ₦",Number(t.target).toLocaleString()]}),e.jsxs("span",{children:[Math.round(t.amount/t.target*100),"% Achieved"]})]}):e.jsx("span",{className:"text-dim text-xs",children:"No Target"})}),e.jsx("td",{children:e.jsx("span",{className:`badge ${t.status==="Received"?"badge-success":t.status==="In Progress"?"badge-primary":"badge-neutral"}`,children:t.status})}),e.jsx("td",{className:"text-dim",children:t.date==="Ongoing"?"Ongoing":new Date(t.date).toLocaleDateString()}),e.jsx("td",{className:"text-right relative",children:N?e.jsx("span",{className:"text-xs text-dim italic",children:"System"}):e.jsx("button",{className:"btn-icon-sm opacity-0 group-hover:opacity-100 transition-opacity",onClick:k=>V(k,t,"revenue"),children:e.jsx(le,{size:16})})})]},t.id)})})]})})}),e.jsx("div",{className:"budget-mobile-view budget-mobile-cards",children:je.map(t=>{const N=t.id?.includes("virtual"),k=Number(t.amount)||0,F=Number(t.targetAmount)||0,X=F>0?Math.round(k/F*100):null;return e.jsxs("div",{className:"budget-mobile-card",children:[e.jsxs("div",{className:"mobile-card-top",children:[e.jsxs("div",{className:"mobile-card-title-group",children:[e.jsx("h4",{className:"mobile-card-title",children:t.source}),e.jsxs("div",{className:"mobile-card-tags",children:[e.jsx("span",{className:"badge badge-neutral",children:t.type}),e.jsx("span",{className:`badge ${t.status==="Received"?"badge-success":t.status==="In Progress"?"badge-primary":"badge-neutral"}`,children:t.status})]})]}),e.jsx("div",{className:"mobile-card-actions",children:N?e.jsx("span",{className:"badge badge-primary",style:{fontSize:"0.65rem"},children:"Auto Sync"}):e.jsx("button",{className:"btn-icon-sm",onClick:re=>V(re,t,"revenue"),children:e.jsx(le,{size:18})})})]}),e.jsxs("div",{className:"mobile-card-stats-grid",children:[e.jsxs("div",{className:"mobile-stat-box",children:[e.jsx("span",{className:"mobile-stat-label",children:"Collected Inflow"}),e.jsxs("span",{className:"mobile-stat-val text-success",children:["₦",k.toLocaleString()]})]}),e.jsxs("div",{className:"mobile-stat-box",children:[e.jsx("span",{className:"mobile-stat-label",children:F>0?"Target Goal":"Stream Type"}),F>0?e.jsxs("span",{className:"mobile-stat-val",children:["₦",F.toLocaleString()]}):e.jsx("span",{className:"mobile-stat-val text-dim",children:t.type||"Standard"})]})]}),F>0&&e.jsxs("div",{className:"mobile-card-progress-wrap",children:[e.jsx("div",{className:"mobile-card-progress-track",children:e.jsx("div",{className:"mobile-card-progress-bar bg-success",style:{width:`${Math.min(100,X)}%`}})}),e.jsxs("div",{className:"mobile-card-progress-labels",children:[e.jsxs("span",{children:[X,"% of target reached"]}
559),e.jsxs("span",{children:["Target: ₦",F.toLocaleString()]})]})]}),e.jsx("div",{className:"mobile-card-footer",children:e.jsxs("div",{className:"mobile-card-date",children:[e.jsx(Ce,{size:13}),e.jsx("span",{children:t.date==="Ongoing"?"Live Auto Inflow":new Date(t.date).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})})]})})]},t.id)})})]})}),R&&e.jsx(Lt,{onClose:()=>S(!1),onSave:Qe,eventId:m,organizerId:r?.role==="team_member"?r.organizerId:r?.uid,editingExpense:Y}),q&&e.jsx(It,{onClose:()=>G(!1),onSave:Xe,eventId:m,organizerId:r?.role==="team_member"?r.organizerId:r?.uid,editingRevenue:ye}),l&&e.jsx(At,{expenses:d,revenueStreams:_,onClose:()=>u(!1),onExport:t=>kt(m,v,a,d,_,r?.displayName||r?.email?.split("@")[0]||"Organizer",i,L,t)}),J&&H&&e.jsx(Ft,{eventId:m,organizerId:r?.role==="team_member"?r.organizerId:r?.uid,onClose:()=>K(!1)}),h.id&&vt.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"action-menu-backdrop",onClick:t=>{t.stopPropagation(),M()}}),e.jsx("div",{className:"action-menu action-menu-portaled",style:{position:"fixed",top:`${h.position.top}px`,right:`${h.position.right}px`,zIndex:99999},onClick:t=>t.stopPropagation(),children:h.type==="expense"?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"action-item",onClick:()=>{const t=h.item;M(),Ge(t)},children:[e.jsx(_e,{size:14})," Edit"]}),e.jsxs("button",{className:"action-item text-error",onClick:()=>{const t=h.item;M(),Ye(t)},children:[e.jsx(pe,{size:14})," Delete"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"action-item",onClick:()=>{const t=h.item;M(),He(t)},children:[e.jsx(_e,{size:14})," Edit"]}),e.jsxs("button",{className:"action-item text-error",onClick:()=>{const t=h.item;M(),qe(t)},children:[e.jsx(pe,{size:14})," Delete"]})]})})]}),document.body)]})};export{Gt 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.