1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2180],{2180:(e,t,s)=>{s.r(t),s.d(t,{default:()=>d});var r=s(95155),a=s(12115),i=s(39390),n=s(14585),o=s(76849),l=s(72011);function d(){let{communityId:e,communityData:t,communityRole:s,communityPermissions:d}=(0,l.n)(),[c,u]=(0,a.useState)([]),[p,m]=(0,a.useState)(!0),[h,v]=(0,a.useState)({}),[x,b]=(0,a.useState)({}),y=(0,a.useMemo)(()=>"creator"===s||"admin"===s||!!(null==d?void 0:d.canApproveEvents),[s,d]);async function g(e){v(t=>({...t,[e]:!0})),b(t=>({...t,[e]:""}));try{let t=(0,o.getFunctions)(),s=(0,o.httpsCallable)(t,"approveRevenueSplit");await s({eventId:e})}catch(s){let t=s instanceof Error?s.message:"Failed to approve";b(s=>({...s,[e]:t}))}finally{v(t=>({...t,[e]:!1}))}}async function f(e){let t=prompt("Why are you rejecting this revenue split? (Optional â sent to the host.)","");if(null!==t){v(t=>({...t,[e]:!0})),b(t=>({...t,[e]:""}));try{let s=(0,o.getFunctions)(),r=(0,o.httpsCallable)(s,"rejectRevenueSplit");await r({eventId:e,reason:t||void 0})}catch(s){let t=s instanceof Error?s.message:"Failed to reject";b(s=>({...s,[e]:t}))}finally{v(t=>({...t,[e]:!1}))}}}if((0,a.useEffect)(()=>{if(!e){u([]),m(!1);return}m(!0);let t=(0,i.query)((0,i.collection)(n.db,"events"),(0,i.where)("communityIds","array-contains",e)),s=(0,i.onSnapshot)(t,t=>{let s=[];t.forEach(t=>{var r,a;let i=t.data(),n=i.revenuePolicy;if(!n||"proposed"!==n.approvalStatus)return;let o=Array.isArray(n.splits)?n.splits:[],l=o.find(t=>"community"===t.recipientType&&t.recipientId===e);if(!l)return;let d=o.find(e=>"producer"===e.recipientType)||null,c=n.proposedAt,u=i.startDate;s.push({eventId:t.id,eventName:i.eventName||i.title||i.name||"Untitled event",eventDate:(null==u||null==(r=u.toDate)?void 0:r.call(u))||null,hostUid:i.organizerId||i.createdBy||null,hostDisplay:i.organizerName||i.hostDisplayName||"Host",proposedAt:(null==c||null==(a=c.toDate)?void 0:a.call(c))||null,proposedBy:n.proposedBy||"",splits:o,communityShare:l||null,hostShare:d})}),s.sort((e,t)=>{var s,r;let a=(null==(s=e.proposedAt)?void 0:s.getTime())||0;return((null==(r=t.proposedAt)?void 0:r.getTime())||0)-a}),u(s),m(!1)},e=>{console.error("[community-revenue-splits] subscribe failed:",e),m(!1)});return()=>s()},[e]),!e)return(0,r.jsx)("div",{className:"flex items-center justify-center h-64 studio-body",children:"No community selected"});if(!y)return(0,r.jsx)("div",{className:"p-6 studio-body max-w-md mx-auto text-center",children:"Only community admins can review revenue split proposals."});if(p)return(0,r.jsx)("div",{className:"p-6 studio-body",children:"Loading proposalsâ¦"});let N=!!((null==t?void 0:t.stripeAccountId)&&(t.stripeChargesEnabled||"active"===t.stripeStatus));return(0,r.jsxs)("div",{className:"py-6 sm:p-6 space-y-5 max-w-4xl",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"studio-display",children:"Revenue Splits"}),(0,r.jsxs)("p",{className:"studio-body mt-1 max-w-2xl",children:["Hosts can propose sharing a percentage of ticket revenue with"," ",(null==t?void 0:t.name)||"this community",". Review proposals below. Approved splits lock the moment the event sells its first ticket."]})]}),!N&&(0,r.jsxs)("div",{className:"rounded-xl border border-amber-500/30 bg-amber-500/[0.04] p-4",children:[(0,r.jsx)("h2",{className:"studio-body-strong mb-1",children:"Connect Stripe to receive revenue"}),(0,r.jsxs)("p",{className:"studio-body",children:[(null==t?void 0:t.name)||"This community"," needs a connected Stripe account before splits can pay out. Approve proposals now to lock the terms; payouts will start automatically once Stripe is connected."]})]}),0===c.length&&(0,r.jsxs)("div",{className:"rounded-xl border border-card bg-card p-10 text-center",children:[(0,r.jsx)("h2",{className:"studio-subtitle mb-2",children:"No pending proposals"}),(0,r.jsxs)("p",{className:"studio-body max-w-md mx-auto",children:["When a host proposes a revenue split with"," ",(null==t?void 0:t.name)||"this community",", it'll appear here for review."]})]}),c.length>0&&(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] overflow-hidden",children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_auto_auto_auto] gap-2 sm:gap-4 px-4 py-2.5 bg-white/[0.02] border-b border-white/[0.06] studio-label",children:[(0,r.jsx)("div",{children:"Event"}),(0,r.jsx)("div",{className:"text-right",children:"Community share"}),(0,r.jsx)("div",{className:"text-right",children:"Submitted"}),(0,r.jsx)("div",{className:"w-[156px]"})]}),c.map(e=>{var t,s,a;let i=!!h[e.eventId],n=x[e.eventId],o=e.proposedAt?function(e){let t=Math.round((Date.now()-e.getTime())/6e4);if(t<1)return"just now";if(t<60)return"".concat(t,"m ago");let s=Math.round(t/60);if(s<24)return"".concat(s,"h ago");let r=Math.round(s/24);return r<7?"".concat(r,"d ago"):e.toLocaleDateString()}(e.proposedAt):"â";return(0,r.jsxs)("div",{className:"border-b border-white/[0.04] last:border-b-0",children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_auto_auto_auto] gap-2 sm:gap-4 px-4 py-3 items-center",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("div",{className:"studio-body-strong truncate",children:e.eventName}),(0,r.jsxs)("div",{className:"studio-caption truncate",children:[e.hostDisplay,e.eventDate?" \xb7 ".concat(e.eventDate.toLocaleDateString()):""]})]}),(0,r.jsxs)("div",{className:"text-right",children:[(0,r.jsxs)("div",{className:"text-sm text-positive-ink tabular-nums font-medium",children:[(null==(t=e.communityShare)?void 0:t.shareValue)||0,"%"]}),(0,r.jsxs)("div",{className:"text-[10px] text-t4",children:["host keeps ",(null==(s=e.hostShare)?void 0:s.shareValue)||0,"%"]})]}),(0,r.jsx)("div",{className:"text-[11px] text-t4 tabular-nums",title:(null==(a=e.proposedAt)?void 0:a.toLocaleStr
1ing())||"",children:o}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{type:"button",onClick:()=>g(e.eventId),disabled:i,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-emerald-500 hover:bg-emerald-400 text-white disabled:opacity-50 transition-colors",children:i?"â¦":"Approve"}),(0,r.jsx)("button",{type:"button",onClick:()=>f(e.eventId),disabled:i,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-transparent border border-white/[0.1] hover:bg-white/[0.04] text-t2 disabled:opacity-50 transition-colors",children:"Reject"})]})]}),n&&(0,r.jsx)("p",{className:"text-[11px] text-negative-ink px-4 pb-2 -mt-1",children:n})]},e.eventId)})]})]})}}}]);
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.