1import{c as U,u as I,r as h,t as x,b as f,j as e,L as O,B as r,w as B,y as P,E as $}from"./index-CAgTsS9I.js";import{L as N}from"./Layout-D_oP4nSj.js";import{I as m}from"./input-B8nvoARq.js";import{L as d}from"./label-DqABlbZL.js";import{B as q}from"./badge-Dfqv_Hz3.js";import{S as F,a as W,b as G,c as K,d as V}from"./select-3EqbpN3m.js";import{D as y,d as k,a as C,b as L,c as S}from"./dialog-70VskD_D.js";import{A as H}from"./arrow-left-BuPJNO5W.js";import{P as Q}from"./plus-CYsBLBd-.js";import{E as _}from"./eye-CPGi78pS.js";import{T as J}from"./trending-up-BjbIgK8w.js";import{C as X}from"./copy-njXYZb9-.js";import{P as Y}from"./pencil-BTK4UZ6F.js";import{T as Z}from"./trash-2-B8kvyBWw.js";import"./settings-Dqu1Zn_r.js";import"./check-DXYeM_Sd.js";import"./mail-SHgAPKVI.js";import"./index-CSdx2VRY.js";import"./search-CkMXx1d0.js";import"./user-Bzsp7ULD.js";import"./camera-DxANKcNo.js";import"./shield-check-BgNs-s5f.js";import"./house-CVZTxZpZ.js";import"./useComposition-EK3NmjJ_.js";import"./index-BdQq_4o_.js";import"./chevron-up-BfbD7VDT.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const b=U("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ee=U("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]),j=[{value:"equipment",label:"Equipment",color:"bg-blue-500/20 text-blue-400"},{value:"streaming",label:"Streaming",color:"bg-purple-500/20 text-purple-400"},{value:"tickets",label:"Tickets",color:"bg-green-500/20 text-green-400"},{value:"betting",label:"Betting",color:"bg-amber-500/20 text-amber-400"},{value:"supplements",label:"Supplements",color:"bg-red-500/20 text-red-400"},{value:"merchandise",label:"Merchandise",color:"bg-pink-500/20 text-pink-400"},{value:"training",label:"Training",color:"bg-cyan-500/20 text-cyan-400"},{value:"general",label:"General",color:"bg-zinc-500/20 text-zinc-400"}];function ae(i){return j.find(g=>g.value===i)?.color||"bg-zinc-500/20 text-zinc-400"}function w({link:i,onSave:g,onClose:p}){const[l,c]=h.useState({name:i?.name||"",slug:i?.slug||"",destinationUrl:i?.destinationUrl||"",category:i?.category||"equipment",partner:i?.partner||"",commissionRate:i?.commissionRate||"",description:i?.description||"",imageUrl:i?.imageUrl||"",displayOrder:i?.displayOrder||0}),o=s=>{if(s.preventDefault(),!l.name||!l.slug||!l.destinationUrl){f.error("Name, slug, and URL are required");return}g(l)},u=s=>s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");return e.jsxs("form",{"data-loc":"client/src/pages/AdminAffiliates.tsx:62",onSubmit:o,className:"space-y-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:63",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:64",className:"space-y-2",children:[e.jsx(d,{"data-loc":"client/src/pages/AdminAffiliates.tsx:65",children:"Link Name *"}),e.jsx(m,{"data-loc":"client/src/pages/AdminAffiliates.tsx:66",value:l.name,onChange:s=>{c(t=>({...t,name:s.target.value,slug:i?t.slug:u(s.target.value)}))},placeholder:"e.g. Sidekick Boxing Gloves",className:"bg-black/40 border-border"})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:79",className:"space-y-2",children:[e.jsx(d,{"data-loc":"client/src/pages/AdminAffiliates.tsx:80",children:"Slug * (used in tracking URL)"}),e.jsx(m,{"data-loc":"client/src/pages/AdminAffiliates.tsx:81",value:l.slug,onChange:s=>c(t=>({...t,slug:s.target.value})),placeholder:"e.g. sidekick-gloves",className:"bg-black/40 border-border"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:90",className:"space-y-2",children:[e.jsx(d,{"data-loc":"client/src/pages/AdminAffiliates.tsx:91",children:"Destination URL *"}),e.jsx(m,{"data-loc":"client/src/pages/AdminAffiliates.tsx:92",value:l.destinationUrl,onChange:s=>c(t=>({...t,destinationUrl:s.target.value})),placeholder:"https://partner.com/ref=britishboxers",className:"bg-black/40 border-border"})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:100",className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:101",className:"space-y-2",children:[e.jsx(d,{"data-loc":"client/src/pages/AdminAffiliates.tsx:102",children:"Category"}),e.jsxs(F,{"data-loc":"client/src/pages/AdminAffiliates.tsx:103",value:l.category,onValueChange:s=>c(t=>({...t,category:s})),children:[e.jsx(W,{"data-loc":"client/src/pages/AdminAffiliates.tsx:104",className:"bg-black/40 border-border",children:e.jsx(G,{"data-loc":"client/src/pages/AdminAffiliates.tsx:105"})}),e.jsx(K,{"data-loc":"client/src/pages/AdminAffiliates.tsx:107",children:j.map(s=>e.jsx(V,{"data-loc":"client/src/pages/AdminAffiliates.tsx:109",value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:114",className:"space-y-2",children:[e.jsx(d,{"data-loc":"client/src/pages/AdminAffiliates.tsx:115",children:"Partner"}),e.jsx(m,{"data-loc":"client/src/pages/AdminAffiliates.tsx:116",value:l.partner,onCh
11ange:s=>c(t=>({...t,partner:s.target.value})),placeholder:"e.g. Sidekick Boxing",className:"bg-black/40 border-border"})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:123",className:"space-y-2",children:[e.jsx(d,{"data-loc":"client/src/pages/AdminAffiliates.tsx:124",children:"Commission Rate"}),e.jsx(m,{"data-loc":"client/src/pages/AdminAffiliates.tsx:125",value:l.commissionRate,onChange:s=>c(t=>({...t,commissionRate:s.target.value})),placeholder:"e.g. 20% per sale",className:"bg-black/40 border-border"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:134",className:"space-y-2",children:[e.jsx(d,{"data-loc":"client/src/pages/AdminAffiliates.tsx:135",children:"Description"}),e.jsx(m,{"data-loc":"client/src/pages/AdminAffiliates.tsx:136",value:l.description,onChange:s=>c(t=>({...t,description:s.target.value})),placeholder:"Short description for internal reference",className:"bg-black/40 border-border"})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:144",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:145",className:"space-y-2",children:[e.jsx(d,{"data-loc":"client/src/pages/AdminAffiliates.tsx:146",children:"Image URL (optional)"}),e.jsx(m,{"data-loc":"client/src/pages/AdminAffiliates.tsx:147",value:l.imageUrl,onChange:s=>c(t=>({...t,imageUrl:s.target.value})),placeholder:"https://...",className:"bg-black/40 border-border"})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:154",className:"space-y-2",children:[e.jsx(d,{"data-loc":"client/src/pages/AdminAffiliates.tsx:155",children:"Display Order"}),e.jsx(m,{"data-loc":"client/src/pages/AdminAffiliates.tsx:156",type:"number",value:l.displayOrder,onChange:s=>c(t=>({...t,displayOrder:parseInt(s.target.value)||0})),className:"bg-black/40 border-border"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:165",className:"flex justify-end gap-3 pt-2",children:[e.jsx(r,{"data-loc":"client/src/pages/AdminAffiliates.tsx:166",type:"button",variant:"outline",onClick:p,children:"Cancel"}),e.jsx(r,{"data-loc":"client/src/pages/AdminAffiliates.tsx:167",type:"submit",className:"bg-boxing-red hover:bg-boxing-red/80",children:i?"Update Link":"Create Link"})]})]})}function we(){const{user:i}=I(),[g,p]=h.useState(null),[l,c]=h.useState(!1),[o,u]=h.useState("all"),s=x.useUtils(),{data:t=[]}=x.affiliates.list.useQuery(),{data:A}=x.affiliates.analytics.useQuery(),T=x.affiliates.create.useMutation({onSuccess:()=>{f.success("Affiliate link created"),s.affiliates.list.invalidate(),s.affiliates.analytics.invalidate(),c(!1)},onError:a=>f.error(a.message)}),R=x.affiliates.update.useMutation({onSuccess:()=>{f.success("Affiliate link updated"),s.affiliates.list.invalidate(),p(null)},onError:a=>f.error(a.message)}),M=x.affiliates.delete.useMutation({onSuccess:()=>{f.success("Affiliate link deleted"),s.affiliates.list.invalidate(),s.affiliates.analytics.invalidate()},onError:a=>f.error(a.message)}),E=x.affiliates.update.useMutation({onSuccess:()=>{s.affiliates.list.invalidate(),s.affiliates.analytics.invalidate()}});if(!i||i.role!=="admin")return e.jsx(N,{"data-loc":"client/src/pages/AdminAffiliates.tsx:222",children:e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:223",className:"container py-20 text-center",children:e.jsx("p",{"data-loc":"client/src/pages/AdminAffiliates.tsx:224",className:"text-muted-foreground",children:"Admin access required"})})});const v=o==="all"?t:t.filter(a=>a.category===o),z=a=>{const n=`${window.location.origin}/go/${a}`;navigator.clipboard.writeText(n),f.success("Tracking URL copied to clipboard")};return e.jsx(N,{"data-loc":"client/src/pages/AdminAffiliates.tsx:241",children:e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:242",className:"min-h-screen bg-background",children:e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:243",className:"container py-8",children:[e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:245",className:"flex items-center gap-4 mb-8",children:e.jsx(O,{"data-loc":"client/src/pages/AdminAffiliates.tsx:246",href:"/admin",children:e.jsxs(r,{"data-loc":"client/src/pages/AdminAffiliates.tsx:247",variant:"ghost",size:"sm",className:"gap-2",children:[e.jsx(H,{"data-loc":"client/src/pages/AdminAffiliates.tsx:248",className:"h-4 w-4"})," Back to Admin"]})})}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:253",className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:254",children:[e.jsxs("h1",{"data-loc":"client/src/pages/AdminAffiliates.tsx:255",className:"font-heading text-3xl text-foreground flex items-center gap-3",children:[e.jsx(b,{"data-loc":"client/src/pages/AdminAffiliates.tsx:256",className:"h-8 w-8 text-boxing-red"}),"AFFILIATE ",e.jsx("span",{"data-loc":"client/src/pages/AdminAffiliates.tsx:257",className:"text-boxing-red",children:"LINKS"})]}),e.jsx("p",{"data-loc":"client/src/pages/AdminAffiliates.tsx:259",className:"text-muted-foreground text-sm mt-1",children:"Manage all affiliate partnerships and track performance"})]}),e.jsxs(y,{"data-loc":"client/src/pages/AdminAffiliates.tsx:263",open:l,onOpenChange:c,children:[e.jsx(k,{"data-loc":"client/src/pages/AdminAffiliates.tsx:264",asChild:!0,children:e.jsxs(r,{"data-loc":"client/src/pages/AdminAffiliates.tsx:265",className:"bg-boxing-red hover:bg-boxing-red/80 gap-2",children:[e.jsx(Q,{"data-loc":"client/src/pages/AdminAffiliates.tsx:266",className:"h-4 w-4"})," Add Link"]})}),e.jsxs(C,{"data-loc":"client/src/pages/AdminAffiliates.tsx:269",className:"max-w-2xl bg-card border-border",children:[e.jsx(L,{"data-loc":"client/src/pages/AdminAffiliates.tsx:270",children:e.jsx(S,{"data-loc":"client/src/pages/AdminAffiliates.tsx:271",className:"font-heading text-xl",children:"Create Affiliate Link"})}),e.jsx(w,{"data-loc":"client/src/pages/AdminAffiliates.tsx:273",onSave:a=>T.mutate(a),onClose:()=>c(!1)})]})]})]}),A&&e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:283",className:"grid grid-cols-2 md:grid-cols-5 ga
11p-4 mb-8",children:[{label:"Total Links",value:A.totalLinks,icon:b,color:"text-blue-400"},{label:"Active Links",value:A.activeLinks,icon:_,color:"text-green-400"},{label:"Total Clicks",value:A.totalClicks,icon:ee,color:"text-boxing-red"},{label:"Clicks Today",value:A.clicksToday,icon:J,color:"text-amber-400"},{label:"This Week",value:A.clicksThisWeek,icon:B,color:"text-purple-400"}].map(a=>e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:291",className:"p-4 rounded-xl border border-border bg-card/50",children:[e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:292",className:"flex items-center gap-2 mb-2",children:[e.jsx(a.icon,{"data-loc":"client/src/pages/AdminAffiliates.tsx:293",className:`h-4 w-4 ${a.color}`}),e.jsx("span",{"data-loc":"client/src/pages/AdminAffiliates.tsx:294",className:"text-xs text-muted-foreground uppercase tracking-wider",children:a.label})]}),e.jsx("p",{"data-loc":"client/src/pages/AdminAffiliates.tsx:296",className:`font-heading text-2xl ${a.color}`,children:a.value.toLocaleString()})]},a.label))}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:303",className:"flex items-center gap-2 mb-6 flex-wrap",children:[e.jsxs(r,{"data-loc":"client/src/pages/AdminAffiliates.tsx:304",variant:o==="all"?"default":"outline",size:"sm",onClick:()=>u("all"),className:o==="all"?"bg-boxing-red hover:bg-boxing-red/80":"",children:["All (",t.length,")"]}),j.map(a=>{const n=t.filter(D=>D.category===a.value).length;return n===0?null:e.jsxs(r,{"data-loc":"client/src/pages/AdminAffiliates.tsx:316",variant:o===a.value?"default":"outline",size:"sm",onClick:()=>u(a.value),className:o===a.value?"bg-boxing-red hover:bg-boxing-red/80":"",children:[a.label," (",n,")"]},a.value)})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:330",className:"rounded-xl border border-border bg-card/50 overflow-hidden",children:[e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:331",className:"grid grid-cols-12 gap-2 px-4 py-3 bg-black/30 border-b border-border text-[10px] font-heading uppercase tracking-wider text-muted-foreground",children:[e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:332",className:"col-span-3",children:"Name / Partner"}),e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:333",className:"col-span-2",children:"Category"}),e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:334",className:"col-span-2",children:"Commission"}),e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:335",className:"col-span-1 text-center",children:"Clicks"}),e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:336",className:"col-span-1 text-center",children:"Status"}),e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:337",className:"col-span-3 text-right",children:"Actions"})]}),v.length===0?e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:341",className:"p-12 text-center",children:[e.jsx(b,{"data-loc":"client/src/pages/AdminAffiliates.tsx:342",className:"h-12 w-12 text-muted-foreground/30 mx-auto mb-4"}),e.jsx("p",{"data-loc":"client/src/pages/AdminAffiliates.tsx:343",className:"text-muted-foreground",children:"No affiliate links yet. Add your first one above."})]}):v.map(a=>e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:347",className:"grid grid-cols-12 gap-2 px-4 py-3 items-center border-b border-border/30 last:border-0 hover:bg-black/20 transition-colors",children:[e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:348",className:"col-span-3",children:[e.jsx("p",{"data-loc":"client/src/pages/AdminAffiliates.tsx:349",className:"font-heading text-sm text-foreground truncate",children:a.name}),e.jsx("p",{"data-loc":"client/src/pages/AdminAffiliates.tsx:350",className:"text-[10px] text-muted-foreground truncate",children:a.partner||"â"})]}),e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:352",className:"col-span-2",children:e.jsx(q,{"data-loc":"client/src/pages/AdminAffiliates.tsx:353",className:`${ae(a.category)} text-[10px]`,children:a.category})}),e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:357",className:"col-span-2",children:e.jsx("span",{"data-loc":"client/src/pages/AdminAffiliates.tsx:358",className:"text-xs text-muted-foreground",children:a.commissionRate||"â"})}),e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:360",className:"col-span-1 text-center",children:e.jsx("span",{"data-loc":"client/src/pages/AdminAffiliates.tsx:361",className:"font-heading text-sm text-boxing-red",children:a.clickCount})}),e.jsx("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:363",className:"col-span-1 text-center",children:e.jsx(P,{"data-loc":"client/src/pages/AdminAffiliates.tsx:364",checked:a.isActive,onCheckedChange:n=>E.mutate({id:a.id,isActive:n})})}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:369",className:"col-span-3 flex items-center justify-end gap-1",children:[e.jsx(r,{"data-loc":"client/src/pages/AdminAffiliates.tsx:370",variant:"ghost",size:"sm",onClick:()=>z(a.slug),title:"Copy tracking URL",children:e.jsx(X,{"data-loc":"client/src/pages/AdminAffiliates.tsx:376",className:"h-3.5 w-3.5"})}),e.jsx(r,{"data-loc":"client/src/pages/AdminAffiliates.tsx:378",variant:"ghost",size:"sm",onClick:()=>window.open(a.destinationUrl,"_blank"),title:"Visit destination",children:e.jsx($,{"data-loc":"client/src/pages/AdminAffiliates.tsx:384",className:"h-3.5 w-3.5"})}),e.jsxs(y,{"data-loc":"client/src/pages/AdminAffiliates.tsx:386",open:g?.id===a.id,onOpenChange:n=>!n&&p(null),children:[e.jsx(k,{"data-loc":"client/src/pages/AdminAffiliates.tsx:387",asChild:!0,children:e.jsx(r,{"data-loc":"client/src/pages/AdminAffiliates.tsx:388",variant:"ghost",size:"sm",onClick:()=>p(a),children:e.jsx(Y,{"data-loc":"client/src/pages/AdminAffiliates.tsx:389",className:"h-3.5 w-3.5"})})}),e.jsxs(C,{"data-loc":"client/src/pages/AdminAffiliates.tsx:392",className:"max-w-2xl bg-card border-border",children:[e.jsx(L,{"data-loc":"client/src/pages/AdminAffiliates.tsx:393",children:e.jsx(S,{"data-loc":"client/src/pages/AdminAffiliates.tsx:394",className:"font-heading text-xl",children:"Edit Affiliate Link"})}),e.jsx(w,{"data-loc":"client/src/pages/AdminAffiliates.tsx:396",link:g,onSave:n=>R.mutate({id:a.id,...n}),onClose:()=>p(null)})]})]}),e.jsx(r,{"data-loc":"client/src/pages/AdminAffiliates.tsx:403",variant:"ghost",size:"sm",onClick:()=>{confirm(`Delete "${a.name}"? This cannot be undone.`)&&M.mutate({id:a.id})},className:"text-red-400 hover:text-red-300",children:e.jsx(Z,{"data-loc":"client/src/pages/AdminAffiliates.tsx:413",className:"h-3.5 w-3.5"})})]})]},a.id))]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminAffiliates.tsx:422",className:"mt-6 p-4 rounded-xl border border-boxing-gold/20 bg-boxing-gold/5",children:[e.jsx("h3",{"data-loc":"client/src/pages/AdminAffiliates.tsx:423",className:"font-heading text-sm text-boxing-gold mb-2",children:"HOW TRACKING WORKS"}),e.jsxs("p",{"data-loc":"client/src/pages/AdminAffiliates.tsx:424",className:"text-xs text-muted-foreground",children:["Each affiliate link gets a tracking URL like ",e.jsx("code",{"data-loc":"client/src/pages/AdminAffiliates.tsx:425",className:"text-boxing-gold bg-black/30 px-1 rounded",children:"/go/your-slug"}),". When a user clicks it, the click is recorded with their user ID, referrer page, and timestamp, then they're redirected to the destination URL. Use the copy button to get the full tracking URL for any link."]})]})]})})})}export{we 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.