1import{a as C,j as e}from"./vendor-radix-DA_aSpdM.js";import{g as J,a as E,B as m,E as l,G as n,I as d,F as c,C as P,J as _,X,k as B,l as R,m as A,n as K,o as Q,p as z,f as b}from"./App-B5Gw_pr3.js";import{u as H}from"./useMutation-C6S-pLIW.js";import{A as W}from"./AdminLayout-nimK7lg5.js";import{T as Y,a as Z,b as w,c as S}from"./tabs-Bc3EQd27.js";import{B as ee}from"./badge-B-Ty_vzC.js";import{I as L}from"./input-Be8YzUgr.js";import{L as j}from"./label-C-UxXqOz.js";import{T as se}from"./textarea-n-HpBHGA.js";import{T as ae,a as te,b as O,c as p,d as ie,e as u}from"./table-3R3SFTii.js";import{S as re,a as le,b as ne,c as de,d as g}from"./select-Cs9UswgO.js";import{supabase as v}from"./client-CfsuD3lc.js";import{U as ce}from"./user-plus-ZjXM7JyH.js";import{U as k}from"./users-BR4IszS0.js";import{M as oe}from"./mail-DDgusAuE.js";import{D as me}from"./dollar-sign-XmxulMHk.js";import{C as xe}from"./chart-column-fxXAAZC4.js";import{C as he}from"./credit-card-dMGg-XQc.js";import{F as pe}from"./file-text-OpyKyVh6.js";import{E as ue}from"./ellipsis-B_pCyYij.js";import{f as je}from"./format-CExLiZ08.js";import"./vendor-supabase-BQ1HIAaS.js";import"./index-C1MkrzIu.js";import"./sentry-kztijHPz.js";import"./platformErrorLogger-4hUhfrtL.js";import"./lazyWithRetry-DxnkR6rW.js";import"./edgeFunctionClient-Cktd4gAf.js";import"./SkipToContent-CRgQc9eq.js";import"./brand-logo-kjEenLET.js";import"./sheet-BHtbuGFR.js";import"./separator-Cgp4LhR9.js";import"./ImpersonationToggle-BRocflVz.js";import"./dropdown-menu-ChdUSMQt.js";import"./chevron-right-Cmx-b24l.js";import"./circle-DL6kpMyo.js";import"./shield-C-xd0eAw.js";import"./user-CgX6Dyy8.js";import"./crown-D0qgxAkK.js";import"./chevron-down-BVDfP_2L.js";import"./selfHealingClient-gRPkGxKK.js";import"./edgeFunctionErrors-tek4dUTq.js";import"./useLandingPagePermissions-BjPztEie.js";import"./collapsible-_UOuurKf.js";import"./message-square-DFAlivbY.js";import"./search-BFm-z-Ci.js";import"./activity-DRKg8dQb.js";import"./trending-up-l4bIqg9u.js";import"./gauge-BRHHaukB.js";import"./heart-YBbuRWzl.js";import"./phone-Cs-wLLGh.js";import"./image-CqJayY8t.js";import"./video-D1DWu8bZ.js";import"./star-1ED16WG2.js";import"./wand-sparkles-Db2hkwxf.js";import"./sparkles-D-iVX4_g.js";import"./eye-WQc0jBQG.js";import"./file-plus-D7lTECvR.js";import"./circle-user-Co-3pjw4.js";import"./trash-2-B59JfgoK.js";import"./brain-D0GmRisc.js";import"./mic-wZvsWghy.js";import"./headphones-RLJv_3gl.js";import"./briefcase-C-ZD2yWu.js";import"./sliders-vertical-kFQXeN6m.js";import"./layers-C8ORVey8.js";import"./bot-BCTcZgdo.js";import"./DebugPanel-BwQGyL_D.js";import"./copy-B1KPSnbw.js";import"./minimize-2-cUlE5igx.js";import"./scroll-text-DXxYYgQf.js";import"./shield-check-DAIRPbOF.js";import"./arrow-left-DFNdcU_9.js";import"./log-out-CtF_CrgZ.js";import"./useKeyboardVisibility-ByIRFiiI.js";import"./useSafeTimers-Dtwb407y.js";import"./globe-Cvbm9E-T.js";import"./flask-conical-CnxH0GOd.js";import"./calendar-fhbGUQ2x.js";import"./palette-Dz_xSOuh.js";import"./clipboard-check-Cs7z8jbJ.js";import"./message-circle-D3WZC271.js";import"./hash-DOoXCYFm.js";import"./scale-4QH1X5M8.js";import"./chevron-up-BctWVrXv.js";import"./en-US-B63PQzQM.js";import"./constructFrom-rJN6zrQ_.js";function Js(){var q;const[U,V]=C.useState("creators"),[$,y]=C.useState(!1),[t,T]=C.useState(null),[r,x]=C.useState({display_name:"",legal_name:"",email:"",royalty_percentage:"10",bio:""}),f=J(),{data:N,isLoading:G}=E({queryKey:["licensed-creators"],queryFn:async()=>{const{data:s,error:a}=await v.from("licensed_creators").select("*").order("created_at",{ascending:!1});if(a)throw a;return s}}),{data:i}=E({queryKey:["creator-stats"],queryFn:async()=>{const{data:s}=await v.from("licensed_creators").select("status"),a=(s==null?void 0:s.length)||0,h=(s==null?void 0:s.filter(I=>I.status==="approved").length)||0,o=(s==null?void 0:s.filter(I=>I.status==="pending").length)||0;return{total_creators:a,active_creators:h,pending_invites:o,total_payouts_this_month:0}}}),F=H({mutationFn:async s=>{const{data:{user:a}}=await v.auth.getUser(),{data:h,error:o}=await v.from("licensed_creators").insert({display_name:s.display_name,legal_name:s.legal_name,email:s.email,royalty_percentage:parseFloat(s.royalty_percentage),bio:s.bio||null,invited_by:a==null?void 0:a.id,status:"pending"}).select().single();if(o)throw o;return h},onSuccess:()=>{b.success("Creator invited successfully!"),y(!1),x({display_name:"",legal_name:"",email:"",royalty_percentage:"10",bio:""}),f.invalidateQueries({queryKey:["licensed-creators"]}),f.invalidateQueries({queryKey:["creator-stats"]})},onError:s=>{b.error("Failed to invite creator: "+s.message)}}),D=H({mutationFn:async({id:s,status:a})=>{const h={status:a};a==="approved"&&(h.approved_at=new Date().toISOString());const{error:o}=await v.from("licensed_creators").update(h).eq("id",s);if(o)throw o},onSuccess:()=>{b.success("Creator status updated!"),f.invalidateQueries({queryKey:["licensed-creators"]}),f.invalidateQueries({queryKey:["creator-stats"]})},onError:s=>{b.error("Failed to update status: "+s.message)}}),M=s=>{const a={pending:"secondary",approved:"default",rejected:"destructive",suspended:"outline"};return e.jsx(ee,{variant:a[s]||"secondary",children:s})};return e.jsx(W,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold",children:"Creator Licensing"}),e.jsx("p",{className:"text-muted-foreground text-sm md:text-base",children:"Manage licensed creators, royalties, and payouts"})]}),e.jsxs(m,{size:"sm",onClick:()=>y(!0),children:[e.jsx(ce,{className:"h-4 w-4 mr-1.5"}),"Invite Creator"]})]}),e.jsxs("div",{className:"grid gap-3 md:gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsxs(l,{children:[e.jsxs(n,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Total Creators"}),e.jsx(k,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(c,{children:e.jsx("div",{className:"text-2xl font-bold",children:(i==null?void 0:i.total_creators)||0})})]}),e.jsxs(l,{children:[e.jsxs(n,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Active Creators"}),e.jsx(P,{className:"h-4 w-4 text-green-600"})]}),e.jsx(c,{children:e.jsx("div",{className:"text-2xl font-bold",children:(i==null?void 0:i.active_creators)||0})})]}),e.jsxs(l,{children:[e.jsxs(n,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(oe,{className:"h-4 w-4 text-yellow-600"})]}),e.jsx(c,{children:e.jsx("div",{className:"text-2xl font-bold",children:(i==null?void 0:i.pending_invites)||0})})]}),e.jsxs(l,{children:[e.jsxs(n,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Payouts This Month"}),e.jsx(me,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(c,{children:e.jsxs("div",{className:"text-2xl font-bold",children:["$",((q=i==null?void 0:i.total_payouts_this_month)==null?void 0:q.toFixed(2))||"0.00"]})})]})]}),e.jsxs(Y,{value:U,onValueChange:V,children:[e.jsx("div",{className:"overflow-x-auto -mx-4 px-4 md:mx-0 md:px-0",children:e.jsxs(Z,{className:"inline-flex w-max md:w-auto",children:[e.jsxs(w,{value:"creators",className:"flex items-center gap-1 md:gap-2",children:[e.jsx(k,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Creators"})]}),e.jsxs(w,{value:"royalties",className:"flex items-center gap-1 md:gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Royalties"})]}),e.jsxs(w,{value:"payouts",className:"flex items-center gap-1 md:gap-2",children:[e.jsx(he,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Payouts"})]}),e.jsxs(w,{value:"contracts",className:"flex items-center gap-1 md:gap-2",children:[e.jsx(pe,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]})]})}),e.jsx(S,{value:"creators",className:"space-y-4",children:e.jsxs(l,{children:[e.jsxs(n,{children:[e.jsx(d,{children:"Licensed Creators"}),e.jsx(_,{children:"Manage talent who have licensed their voice and likeness"})]}),e.jsx(c,{className:"p-0 md:p-6",children:G?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):N!=null&&N.length?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ae,{children:[e.jsx(te,{children:e.jsxs(O,{children:[e.jsx(p,{children:"Creator"}),e.jsx(p,{children:"Email"}),e.jsx(p,{children:"Status"}),e.jsx(p,{children:"Royalty %"}),e.jsx(p,{children:"Invited"}),e.jsx(p,{className:"text-right",children:"Actions"})]})}),e.jsx(ie,{children:N.map(s=>e.jsxs(O,{children:[e.jsx(u,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center",children:s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:"",className:"h-10 w-10 rounded-full object-cover"}):e.jsx(k,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.display_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.legal_name})]})]})}),e.jsx(u,{children:s.email}),e.jsx(u,{children:M(s.status)}),e.jsxs(u,{children:[s.royalty_percentage,"%"]}),e.jsx(u,{children:je(new Date(s.invited_at),"MMM d, yyyy")}),e.jsx(u,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx(m,{size:"sm",variant:"outline",onClick:()=>D.mutate({id:s.id,status:"approved"}),children:e.jsx(P,{className:"h-4 w-4"})}),e.jsx(m,{size:"sm",variant:"outline",onClick:()=>D.mutate({id:s.id,status:"rejected"}),children:e.jsx(X,{className:"h-4 w-4"})})]}),e.jsx(m,{size:"sm",variant:"ghost",onClick:()=>T(s),children:e.jsx(ue,{className:"h-4 w-4"})})]})})]},s.id))})]})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No creators yet. Invite your first creator to get started."})})]})}),e.jsx(S,{value:"royalties",children:e.jsxs(l,{children:[e.jsxs(n,{children:[e.jsx(d,{children:"Royalty Calculations"}),e.jsx(_,{children:"View usage-based royalty earnings for each creator"})]}),e.jsx(c,{children:e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Royalty data will appear here once creators have usage."})})]})}),e.jsx(S,{value:"payouts",children:e.jsxs(l,{children:[e.jsxs(n,{children:[e.jsx(d,{children:"Payout History"}),e.jsx(_,{children:"Track payments made to licensed creators"})]}),e.jsx(c,{children:e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No payouts have been processed yet."})})]})}),e.jsx(S,{value:"contracts",children:e.jsxs(l,{children:[e.jsxs(n,{children:[e.jsx(d,{children:"License Agreements"}),e.jsx(_,{children:"Manage licensing contracts and terms"})]}),e.jsx(c,{children:e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Contract management coming soon."})})]})})]}),e.jsx(B,{open:$,onOpenChange:y,children:e.jsxs(R,{className:"max-w-md",children:[e.jsxs(A,{children:[e.jsx(K,{children:"Invite Creator"}),e.jsx(Q,{children:"Send an invitation to license their voice and likeness"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Display Name *"}),e.jsx(L,{value:r.display_name,onChange:s=>x(a=>({...a,display_name:s.target.value})),placeholder:"Stage name or public name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Legal Name *"}),e.jsx(L,{value:r.legal_name,onChange:s=>x(a=>({...a,legal_name:s.target.value})),placeholder:"Full legal name for contracts"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Email *"}),e.jsx(L,{type:"email",value:r.email,onChange:s=>x(a=>({...a,email:s.target.value})),placeholder:"[email protected]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Royalty Percentage"}),e.jsxs(re,{value:r.royalty_percentage,onValueChange:s=>x(a=>({...a,royalty_percentage:s})),children:[e.jsx(le,{children:e.jsx(ne,{})}),e.jsxs(de,{children:[e.jsx(g,{value:"5",children:"5%"}),e.jsx(g,{value:"10",children:"10%"}),e.jsx(g,{value:"15",children:"15%"}),e.jsx(g,{value:"20",children:"20%"}),e.jsx(g,{value:"25",children:"25%"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Bio"}),e.jsx(se,{value:r.bio,onChange:s=>x(a=>({...a,bio:s.target.value})),placeholder:"Brief description of the creator",rows:3})]})]}),e.jsxs(z,{children:[e.jsx(m,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(m,{onClick:()=>F.mutate(r),disabled:!r.display_name||!r.legal_name||!r.email||F.isPending,children:F.isPending?"Sending...":"Send Invitation"})]})]})}),e.jsx(B,{open:!!t,onOpenChange:()=>T(null),children:e.jsxs(R,{className:"max-w-lg",children:[e.jsxs(A,{children:[e.jsx(K,{children:t==null?void 0:t.display_name}),e.jsx(Q,{children:"Creator details and management"})]}),t&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"Legal Name"}),e.jsx("div",{className:"font-medium",children:t.legal_name})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"Email"}),e.jsx("div",{className:"font-medium",children:t.email})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"Status"}),e.jsx("div",{children:M(t.status)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"Royalty Rate"}),e.jsxs("div",{className:"font-medium",children:[t.royalty_percentage,"%"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"Minimum Payout"}),e.jsxs("div",{className:"font-medium",children:["$",t.minimum_payout]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"Payout Method"}),e.jsx("div",{className:"font-medium capitalize",children:t.payout_method})]})]}),t.bio&&e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground text-sm mb-1",children:"Bio"}),e.jsx("p",{className:"text-sm",children:t.bio})]})]}),e.jsx(z,{children:e.jsx(m,{variant:"outline",onClick:()=>T(null),children:"Close"})})]})})]})})}export{Js 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.