1import{c as As,e as Ps,r,f as qe,j as e,C as ee,d as se,p as xe,S as ze,s as Ke,i as f,z as is,a as ae,I as F,B as c,X as ta,g as z,A as Fs,m as Ms,n as Ds,U as Qe,h as Ye,k as ra,u as ia,dn as la,b4 as pe,l as V,T as na,o as ls,D as E,a1 as ue,v as ns,aF as oa,aG as ca,aH as da,aI as ma,aL as Le,aM as he,_ as ua,dp as ha,t as xa,aw as pa,ax as fa,ay as os,aA as cs,aq as ds,ar as ms,as as us,at as hs,au as xs,aB as w,aN as ps,x as ja,E as q}from"./index-CAQ9C6-z.js";import{S as K,a as Q,b as H,c as G,d as m}from"./select-C1jcuWaT.js";import{T as Es,a as $s,b as te,c as p,d as Rs,e as x}from"./table-BaZ6TUhP.js";import{S as Is}from"./search-D3WXbl0Z.js";import{A as Oe}from"./arrow-up-down-CuEcp_85.js";import{f as ga}from"./format-DECx0Hkk.js";import{f as He}from"./formatDistanceToNow-CxJ9KK4h.js";import{E as va}from"./external-link-CGowBU-0.js";import{S as Je}from"./star-QjPncnq2.js";import{A as fs,a as js,b as gs,c as vs,d as ws,e as Ns,f as ys,g as bs}from"./alert-dialog-B8z1m0Cj.js";import{R as wa,a as Cs}from"./radio-group-Cfm-rU2o.js";import{S as Na}from"./index-DHaSN7w9.js";import{A as ya}from"./AdminBreadcrumb-DnS-FtUE.js";import{e as ba}from"./csv-phEISFTt.js";import{U as Ge}from"./user-BbKRbDSw.js";import{B as Us}from"./building-DsnOM5j6.js";import{U as Be}from"./user-plus-B_OmsbPc.js";import{D as Ca}from"./download-BvX1Szdt.js";import{F as Sa}from"./filter-B4etKnWY.js";import{I as _s,T as Ta}from"./twitter-DrtDkoo_.js";import{Y as ka}from"./youtube-BLmI--jM.js";import{E as Aa}from"./ellipsis-vertical-DNjtDyRc.js";import{K as Pa}from"./key-round-C_YQB3Q8.js";import{T as Fa}from"./trash-2-CJsVXXEd.js";import{C as Ma}from"./chevron-left-B-A6hXmU.js";import"./index-BdQq_4o_.js";import"./index-Q3UH4NY9.js";import"./chevron-down--E-1bxpl.js";import"./chevron-up-BOfZRiUg.js";import"./en-US-K2-Byqu-.js";import"./differenceInCalendarDays-BvXbP6kq.js";import"./endOfMonth-Cj4XZLSX.js";import"./differenceInMilliseconds-C7R6uDOC.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 Da=As("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/** 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 Ea=As("Infinity",[["path",{d:"M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z",key:"1z0uae"}]]);function $a(){const[,l]=Ps(),[$,N]=r.useState(""),[M,fe]=r.useState(""),[D,Y]=r.useState("all"),[R,je]=r.useState("completedAt"),[J,C]=r.useState("desc"),T=r.useRef(null);r.useEffect(()=>(T.current&&clearTimeout(T.current),T.current=setTimeout(()=>fe($.trim()),300),()=>{T.current&&clearTimeout(T.current)}),[$]);const S=["/api/admin/media-coverage/priority-pool",{search:M,tier:D,sort:R,direction:J}],{data:d,isLoading:ge,error:I}=qe({queryKey:S,queryFn:async()=>{const a=new URLSearchParams;M&&a.set("search",M),a.set("tier",D),a.set("sort",R),a.set("direction",J);const u=await fetch(`/api/admin/media-coverage/priority-pool?${a.toString()}`,{credentials:"include"});if(!u.ok)throw new Error("Failed to load priority pool");return u.json()}}),U=a=>{R===a?C(u=>u==="asc"?"desc":"asc"):(je(a),C(a==="name"?"asc":"desc"))},_=a=>a==="all_access_creator"?e.jsxs(f,{className:"bg-primary text-primary-foreground gap-1 shadow-sm",children:[e.jsx(Je,{className:"w-3 h-3"}),"All Access"]}):e.jsxs(f,{className:"bg-accent text-accent-foreground gap-1 shadow-sm",children:[e.jsx(Ye,{className:"w-3 h-3"}),"VIP"]}),re=()=>d!=null&&d.gateCourseConfigured?e.jsxs("div",{className:"text-center py-12 px-4","data-testid":"empty-no-members",children:[e.jsx(ze,{className:"w-12 h-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-base font-medium mb-1",children:"No creators in the priority pool yet"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["VIP and All Access creators who finish every module of"," ",e.jsx("span",{className:"font-medium",children:d.gateCourseTitle??"the gate course"})," will appear here automatically."]})]}):e.jsxs("div",{className:"text-center py-12 px-4","data-testid":"empty-no-gate-course",children:[e.jsx(is,{className:"w-12 h-12 mx-auto text-muted-foreground
11/50 mb-4"}),e.jsx("p",{className:"text-base font-medium mb-1",children:"No Media Coverage gate course configured"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Designate a course as the Media Coverage gate from the Education page to start tracking the priority pool."}),e.jsx(c,{variant:"outline",onClick:()=>l("/admin/education"),"data-testid":"button-go-to-education",children:"Go to Education"})]});return e.jsxs(ee,{children:[e.jsx(se,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-2","data-testid":"text-page-title",children:[e.jsx(ze,{className:"w-5 h-5"}),"Media Coverage Priority Pool"]}),e.jsx(Ke,{className:"mt-1",children:"VIP and All Access creators who completed every module of the Media Coverage gate course. Membership is derived live from course progress."})]}),(d==null?void 0:d.gateCourseTitle)&&e.jsxs(f,{variant:"outline",className:"gap-1","data-testid":"badge-gate-course",children:[e.jsx(is,{className:"w-3 h-3"}),"Gate course: ",d.gateCourseTitle]})]})}),e.jsxs(ae,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(Is,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(F,{placeholder:"Search by name or email...",value:$,onChange:a=>N(a.target.value),className:"pl-9","data-testid":"input-search"})]}),e.jsxs(K,{value:D,onValueChange:a=>Y(a),children:[e.jsx(Q,{className:"w-[180px]","data-testid":"select-tier",children:e.jsx(H,{placeholder:"All tiers"})}),e.jsxs(G,{children:[e.jsx(m,{value:"all",children:"All tiers"}),e.jsx(m,{value:"premium_creator",children:"VIP"}),e.jsx(m,{value:"all_access_creator",children:"All Access"})]})]}),(M||D!=="all")&&e.jsxs(c,{variant:"ghost",size:"sm",onClick:()=>{N(""),Y("all")},"data-testid":"button-clear-filters",children:[e.jsx(ta,{className:"w-4 h-4 mr-1"}),"Clear"]}),e.jsxs("span",{className:"ml-auto text-sm text-muted-foreground","data-testid":"text-result-count",children:[(d==null?void 0:d.members.length)??0," ",(d==null?void 0:d.members.length)===1?"creator":"creators"]})]}),ge?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((a,u)=>e.jsx(z,{className:"h-14 w-full"},u))}):I?e.jsx("div",{className:"text-center py-12 text-destructive","data-testid":"text-error",children:"Failed to load the priority pool."}):!d||d.members.length===0?re():e.jsxs(Es,{children:[e.jsx($s,{children:e.jsxs(te,{children:[e.jsx(p,{children:e.jsxs(c,{variant:"ghost",size:"sm",className:"h-8 px-2 -ml-2 font-medium",onClick:()=>U("name"),"data-testid":"sort-name",children:["Creator",e.jsx(Oe,{className:"w-3 h-3 ml-1"})]})}),e.jsx(p,{children:"Tier"}),e.jsx(p,{children:e.jsxs(c,{variant:"ghost",size:"sm",className:"h-8 px-2 -ml-2 font-medium",onClick:()=>U("completedAt"),"data-testid":"sort-completed-at",children:["Course Completed",e.jsx(Oe,{className:"w-3 h-3 ml-1"})]})}),e.jsx(p,{children:e.jsxs(c,{variant:"ghost",size:"sm",className:"h-8 px-2 -ml-2 font-medium",onClick:()=>U("activeApplications"),"data-testid":"sort-active-apps",children:["Active MC Applications",e.jsx(Oe,{className:"w-3 h-3 ml-1"})]})}),e.jsx(p,{className:"w-[80px] text-right",children:"Actions"})]})}),e.jsx(Rs,{children:d.members.map(a=>{var u,ie;return e.jsxs(te,{"data-testid":`row-pool-member-${a.userId}`,children:[e.jsx(x,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Fs,{className:"w-8 h-8",children:[e.jsx(Ms,{src:a.profileImageUrl??""}),e.jsx(Ds,{className:"text-xs",children:(((u=a.firstName)==null?void 0:u[0])??"")+(((ie=a.lastName)==null?void 0:ie[0])??"")})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium","data-testid":`text-name-${a.userId}`,children:(a.firstName||"")+" "+(a.lastName||"")}),a.email&&e.jsx("a",{href:`mailto:${a.email}`,className:"text-xs text-muted-foreground hover:text-primary","data-testid":`link-email-${a.userId}`,children:a.email})]})]})}),e.jsx(x,{children:_(a.tier)}),e.jsx(x,{children:a.completedAt?e.jsxs("div",{className:"flex flex-col","data-testid":`text-completed-${a.userId}`,children:[e.jsx("span",{className:"text-sm",children:ga(new Date(a.completedAt),"MMM d, yyyy")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:He(new Date(a.completedAt),{addSuffix:!0})})]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"-"})}),e.jsx(x,{children:e.jsxs(f,{variant:a.activeMediaCoverageApplicationCount>0?"default":"secondary","data-testid":`badge-active-apps-${a.userId}`,children:[e.jsx(Qe,{className:"w-3 h-3 mr-1"}),a.activeMediaCoverageApplicationCount]})}),e.jsx(x,{className:"text-right",children:e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>l(`/admin/users?userId=${a.userId}`),title:"View user","data-testid":`button-view-user-${a.userId}`,children:e.jsx(va,{className:"w-4 h-4"})})})]},a.userId)})})]})]})]})}const Ss={instagram:{label:"Instagram",icon:_s,urlPrefix:"https://instagram.com/"},youtube:{label:"YouTube",icon:ka,urlPrefix:"https://youtube.com/@"},tiktok:{label:"TikTok",icon:Na,urlPrefix:"https://tiktok.com/@"},twitter:{label:"Twitter",icon:Ta,urlPrefix:"https://twitter.com/"}};function Ra(l){return l>=1e6?`${(l/1e6).toFixed(l>=1e7?0:1).replace(/\.0$/,"")}M`:l>=1e3?`${(l/1e3).toFixed(l>=1e4?0:1).replace(/\.0$/,"")}
11K`:l.toLocaleString()}const Ls=["users","media-coverage-pool"],Ve=[{value:"creator",label:"Creator",description:"Standard creator account.",icon:Ge,iconClass:"text-muted-foreground"},{value:"premium_creator",label:"VIP",description:"Premium creator with extra perks.",icon:Ye,iconClass:"text-accent-foreground"},{value:"all_access_creator",label:"All Access",description:"Top-tier creator membership.",icon:Je,iconClass:"text-primary"},{value:"brand",label:"Brand",description:"Brand / partner account.",icon:Us,iconClass:"text-muted-foreground"},{value:"tfb_team",label:"TFB Team",description:"Internal Festival Babes staff. Admin-grade access today; financial / stats pages will be reserved for true admins later.",icon:pe,iconClass:"text-primary"},{value:"admin",label:"Admin",description:"Full administrative access. Reserved for a small set of users (e.g. Kat).",icon:pe,iconClass:"text-primary"}],Ia=[{label:"7 days",value:7,unit:"days"},{label:"30 days",value:30,unit:"days"},{label:"3 months",value:3,unit:"months"},{label:"6 months",value:6,unit:"months"},{label:"1 year",value:12,unit:"months"}],Ts={days:24*60*60*1e3,weeks:7*24*60*60*1e3,months:30*24*60*60*1e3},ks=l=>{const N=new URLSearchParams(l).get("tab");return Ls.includes(N)?N:"users"};function ft(){const{toast:l}=ra(),{user:$}=ia(),N=la($),M=N?Ve:Ve.filter(s=>s.value==="creator"||s.value==="brand"),[fe,D]=Ps(),[Y,R]=r.useState(()=>typeof window<"u"?ks(window.location.search):"users"),[je,J]=r.useState(""),[C,T]=r.useState(""),S=r.useRef(null);r.useEffect(()=>{if(typeof window>"u")return;const s=()=>{const t=ks(window.location.search);R(o=>o===t?o:t)};return s(),window.addEventListener("popstate",s),()=>window.removeEventListener("popstate",s)},[fe]);const d=r.useCallback(s=>{const t=Ls.includes(s)?s:"users";R(t);const o=t==="users"?"/admin/users":`/admin/users?tab=${t}`;D(o,{replace:!1})},[D]),ge=r.useCallback(s=>{J(s),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{T(s),u(1)},400)},[]);r.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const[I,U]=r.useState("all"),[_,re]=r.useState("all"),[a,u]=r.useState(1),ie=r.useCallback(s=>{U(s),u(1)},[]),Os=r.useCallback(s=>{re(s),u(1)},[]),[h,le]=r.useState(null),[Bs,ve]=r.useState(!1),[Vs,we]=r.useState(!1),[k,Ne]=r.useState(""),[ye,We]=r.useState(!1),[qs,W]=r.useState(!1),[ne,oe]=r.useState(""),[L,be]=r.useState(""),[Ze,Ce]=r.useState(""),[Xe,Se]=r.useState(""),[es,Te]=r.useState("creator"),[zs,ce]=r.useState(!1),[y,ke]=r.useState(null),[Ae,ss]=r.useState("creator"),[de,Pe]=r.useState("permanent"),[A,Fe]=r.useState(2),[me,Me]=r.useState("months"),De=10,{data:n,isLoading:Ks,isError:Qs}=qe({queryKey:["/api/admin/users",a,C,I,_],queryFn:async()=>{const s=new URLSearchParams({page:a.toString(),limit:De.toString(),...C&&{search:C},...I!=="all"&&{role:I},..._!=="all"&&{status:_}}),t=await fetch(`/api/admin/users?${s}`,{credentials:"include"});if(!t.ok)throw new Error("Failed to fetch users");return t.json()}}),{data:O}=qe({queryKey:["/api/admin/users/referral-stats"],queryFn:async()=>{const s=await fetch("/api/admin/users/referral-stats",{credentials:"include"});if(!s.ok)throw new Error("Failed to fetch referral stats");return s.json()}});r.useEffect(()=>{n!=null&&n.page&&n.page!==a&&u(n.page)},[n==null?void 0:n.page]);const Hs=V({mutationFn:async s=>q("DELETE",`/api/admin/users/${s}`,{}),onSuccess:()=>{E.invalidateQueries({queryKey:["/api/admin/users"]}),l({title:"Success",description:"User deleted successfully"}),ve(!1),le(null)},onError:()=>{l({title:"Error",description:"Failed to delete user",variant:"destructive"})}}),Ee=V({mutationFn:async()=>(await q("POST","/api/admin/social-media/refresh-followers")).json(),onSuccess:s=>{l({title:"Refresh started",description:s.message??"Counts will populate over the next few minutes."}),setTimeout(()=>{E.invalidateQueries({queryKey:["/api/admin/users"]})},3e4),setTimeout(()=>{E.invalidateQueries({queryKey:["/api/admin/users"]})},12e4)},onError:()=>{l({title:"Error",description:"Could not start the follower refresh. Check server logs.",variant:"destructive"})}}),$e=V({mutationFn:async s=>(await q("POST","/api/admin/users",s)).json(),onSuccess:s=>{E.invalidateQueries({queryKey:["/api/admin/users"]}),l({title:"User created",description:`Account created for ${s.email}.`}),W(!1),oe(""),be(""),Ce(""),Se(""),Te("creator")},onError:s=>{const t=s instanceof Error?s.message:"",o=t.match(/^\d{3}:\s*(.*)$/),i=o?o[1]:t;let j="Failed to create user. Please try again.";try{const g=JSON.parse(i);g!=null&&g.message&&(j=g.message)}catch{i&&(j=i)}j.toLowerCase().includes("already exists")?l({title:"User already exists",description:"A user with that email already has an account. Use Reset Password or Email Password Reset instead.",variant:"destructive"}):l({title:"Error",description:j,variant:"destructive"})}}),Gs=()=>{!ne||!L||$e.mutate({email:ne,password:L,firstName:Ze||void 0,lastName:Xe||void 0,role:es})},Ys=async()=>{We(!0);try{const s=await fetch("/api/admin/users/export",{credentials:"include"});if(!s.ok)throw new Error("Failed to fetch members for export");const o=(await s.json()).members??[];ba(`festival-babes-members-${new Date().toISOString().split("T")[0]}.csv`,["First name","Last name","Email","Membership","Status","Joined","City","State","Phone","Festivals this year","Instagram","Instagram followers","TikTok","TikTok followers","YouTube","YouTube followers","Twitter","Twitter followers","Referred by","Referral code","UTM source","UTM medium","UTM campaign"],o.map(i=>[i.firstName,i.lastName,i.email,i.roleLabel,i.status,i.createdAt?i.createdAt.slice(0,10):"",i.city,i.state,i.phone,i.plannedFestivals,i.instagram,i.instagramFollowers,i.tiktok,i.tiktokFollowers,i.youtube,i.youtubeFollowers,i.twitter,i.twitterFollowers,i.referredBy,i.referralCode,i.utmSource,i.utmMedium,i.utmCampaign])),l({title:"Members exported",description:`${o.length} members downloaded as a CSV.`})}catch{l({title:"Export failed",description:"Couldn't download the member list. Try again.",variant:"destructive"})}finally{We(!1)}},Re=s=>
11{switch(s){case"admin":return e.jsxs(f,{variant:"default",className:"bg-primary shadow-sm",children:[e.jsx(pe,{className:"w-3 h-3 mr-1"}),"Admin"]});case"tfb_team":return e.jsxs(f,{variant:"default",className:"bg-primary shadow-sm",children:[e.jsx(pe,{className:"w-3 h-3 mr-1"}),"TFB Team"]});case"all_access_creator":return e.jsxs(f,{variant:"default",className:"bg-primary shadow-sm",children:[e.jsx(Je,{className:"w-3 h-3 mr-1"}),"All Access"]});case"premium_creator":return e.jsxs(f,{variant:"default",className:"bg-accent shadow-sm",children:[e.jsx(Ye,{className:"w-3 h-3 mr-1"}),"VIP"]});case"creator":return e.jsxs(f,{variant:"secondary",children:[e.jsx(Ge,{className:"w-3 h-3 mr-1"}),"Creator"]});case"brand":return e.jsxs(f,{variant:"outline",className:"border-secondary text-secondary-foreground",children:[e.jsx(Us,{className:"w-3 h-3 mr-1"}),"Brand"]});default:return e.jsx(f,{variant:"outline",children:s})}},Js=s=>{if(!s)return null;const t=typeof s=="string"?new Date(s):s;return Number.isNaN(t.getTime())||t.getTime()<=Date.now()?null:He(t,{addSuffix:!1})},Ie=V({mutationFn:async({userId:s,role:t,expiresAt:o})=>(await q("PUT",`/api/admin/users/${s}/role`,{role:t,expiresAt:o})).json(),onSuccess:s=>{E.invalidateQueries({queryKey:["/api/admin/users"]}),l({title:"Membership updated",description:(s==null?void 0:s.message)??"User membership updated successfully."}),ce(!1),ke(null)},onError:s=>{l({title:"Error",description:Ue(s,"Failed to update membership."),variant:"destructive"})}}),Ws=s=>{ke(s);const t=s.role??"creator",o=M.some(i=>i.value===t)?t:"creator";ss(o),N&&s.roleGrantedUntil?Pe("temporary"):Pe("permanent"),Fe(2),Me("months"),ce(!0)},Zs=()=>{if(!y)return;let s=null;if(de==="temporary"){if(!A||A<=0){l({title:"Invalid duration",description:"Duration must be greater than zero.",variant:"destructive"});return}const t=A*Ts[me];s=new Date(Date.now()+t).toISOString()}Ie.mutate({userId:y.id,role:Ae,expiresAt:s})},as=(()=>{if(de!=="temporary"||!A||A<=0)return null;const s=A*Ts[me];return new Date(Date.now()+s)})(),Ue=(s,t)=>{const o=s instanceof Error?s.message:"",i=o.match(/^\d{3}:\s*(.*)$/),j=i?i[1]:o;if(!j)return t;try{const g=JSON.parse(j);if(g&&typeof g.message=="string")return g.message}catch{}return j||t},Xs=V({mutationFn:async s=>(await q("POST",`/api/admin/users/${s}/send-password-reset`)).json(),onSuccess:s=>{l({title:"Password reset email sent",description:(s==null?void 0:s.message)??"The user has been emailed a password reset link."})},onError:s=>{l({title:"Error",description:Ue(s,"Failed to send password reset email. Please try again."),variant:"destructive"})}}),ea=s=>{Xs.mutate(s)},_e=V({mutationFn:async({userId:s,password:t})=>q("POST",`/api/admin/users/${s}/reset-password`,{password:t}),onSuccess:()=>{E.invalidateQueries({queryKey:["/api/admin/users"]}),l({title:"Success",description:"Password has been reset successfully"}),we(!1),Ne(""),le(null)},onError:s=>{l({title:"Error",description:Ue(s,"Failed to reset password"),variant:"destructive"})}}),sa=()=>{if(!(!h||!k)){if(k.length<8){l({title:"Invalid Password",description:"Password must be at least 8 characters long",variant:"destructive"});return}_e.mutate({userId:h.id,password:k})}},aa=Ks?e.jsx("div",{className:"space-y-6",children:e.jsxs(ee,{children:[e.jsxs(se,{children:[e.jsx(z,{className:"h-6 w-32"}),e.jsx(z,{className:"h-4 w-48"})]}),e.jsx(ae,{children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsx(z,{className:"h-12 w-full"},s))})})]})}):Qs?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"bg-destructive/10 rounded-full p-6 mb-6",children:e.jsx(na,{className:"h-12 w-12 text-destructive"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:"Failed to Load Users"}),e.jsx("p",{className:"text-muted-foreground text-center max-w-md mb-6",children:"We couldn't load the user data. Please check your connection and try again."}),e.jsxs(c,{onClick:()=>E.invalidateQueries({queryKey:["/api/admin/users"]}),"data-testid":"button-retry-users",children:[e.jsx(ls,{className:"h-4 w-4 mr-2"}),"Try Again"]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs(c,{onClick:()=>W(!0),variant:"default",className:"hover-elevate active-elevate-2","data-testid":"button-add-user",children:[e.jsx(Be,{className:"w-4 h-4 mr-2"}),"Add User"]}),e.jsxs(c,{onClick:Ys,variant:"outline",className:"hover-elevate active-elevate-2","data-testid":"button-export-csv",disabled:ye,children:[ye?e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ca,{className:"w-4 h-4 mr-2"}),ye?"Exporting...":"Export all members"]})]}),e.jsxs(ee,{className:"bg-card/50 border-accent/20",children:[e.jsxs(se,{className:"pb-3",children:[e.jsxs(xe,{className:"text-base flex items-center gap-2",children:[e.jsx(Qe,{className:"w-4 h-4 text-primary"}),"Referral Overview"]}),e.jsx(Ke,{children:"Aggregated across all active users"})]}),e.jsx(ae,{children:O?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-2xl font-bold tabular-nums","data-testid":"stat-referred-count",children:O.referredCount}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["of ",O.totalUsers," users referred (",e.jsxs("span",{"data-testid":"text-referred-
11percent",children:[O.referredPercent,"%"]}),")"]})]}),O.topReferrers.length>0?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2",children:"Top referrers"}),O.topReferrers.map((s,t)=>e.jsxs("div",{className:"flex items-center justify-between text-sm py-0.5","data-testid":`top-referrer-${t}`,children:[e.jsx("span",{className:"truncate max-w-[70%]",children:s.name}),e.jsx(f,{variant:"secondary",className:"ml-2 shrink-0",children:s.count})]},s.name)),e.jsx("p",{className:"text-xs text-muted-foreground mt-3 pt-2 border-t border-border/50",children:"Self-reported free text â similar sources may be grouped approximately."})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No referral sources yet."})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{className:"h-8 w-40"}),e.jsx(z,{className:"h-4 w-56"})]})})]}),e.jsxs(ee,{className:"bg-card/50 border-accent/20",children:[e.jsx(se,{children:e.jsx(xe,{className:"text-lg",children:"Filters"})}),e.jsx(ae,{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Is,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-4 h-4"}),e.jsx(F,{placeholder:"Search by name or email...",value:je,onChange:s=>ge(s.target.value),className:"pl-9","data-testid":"input-search-users"})]}),e.jsxs(K,{value:I,onValueChange:ie,children:[e.jsx(Q,{"data-testid":"select-role-filter",children:e.jsx(H,{placeholder:"Filter by role"})}),e.jsxs(G,{children:[e.jsx(m,{value:"all",children:"All Roles"}),e.jsx(m,{value:"creator",children:"Creators"}),e.jsx(m,{value:"premium_creator",children:"VIP Creators"}),e.jsx(m,{value:"all_access_creator",children:"All Access"}),e.jsx(m,{value:"brand",children:"Brands"}),e.jsx(m,{value:"tfb_team",children:"TFB Team"}),e.jsx(m,{value:"admin",children:"Admins"})]})]}),e.jsxs(K,{value:_,onValueChange:Os,children:[e.jsx(Q,{"data-testid":"select-status-filter",children:e.jsx(H,{placeholder:"Filter by status"})}),e.jsxs(G,{children:[e.jsx(m,{value:"all",children:"All Statuses"}),e.jsx(m,{value:"active",children:"Active"}),e.jsx(m,{value:"inactive",children:"Inactive"})]})]}),e.jsxs(c,{variant:"secondary",onClick:()=>{S.current&&clearTimeout(S.current),J(""),T(""),U("all"),re("all"),u(1)},className:"hover-elevate active-elevate-2","data-testid":"button-clear-filters",children:[e.jsx(Sa,{className:"w-4 h-4 mr-2"}),"Clear Filters"]})]})})]}),e.jsxs(ee,{className:"bg-card/50 border-accent/20",children:[e.jsxs(se,{className:"flex flex-row items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-lg",children:"Users"}),e.jsxs(Ke,{children:[(n==null?void 0:n.total)||0," total users ⢠Page ",a," of ",(n==null?void 0:n.totalPages)||1]})]}),e.jsx(c,{variant:"outline",size:"sm",onClick:()=>Ee.mutate(),disabled:Ee.isPending,"data-testid":"button-refresh-follower-counts",children:Ee.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}),"Refreshingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(ls,{className:"w-4 h-4 mr-2"}),"Refresh follower counts"]})})]}),e.jsxs(ae,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Es,{children:[e.jsx($s,{children:e.jsxs(te,{children:[e.jsx(p,{className:"w-[60px]"}),e.jsx(p,{children:"Name"}),e.jsx(p,{children:"Email"}),e.jsx(p,{children:"Socials"}),e.jsx(p,{children:"Top Following"}),e.jsx(p,{children:"Role"}),e.jsx(p,{children:"Created"}),e.jsx(p,{className:"text-right sticky right-0 bg-card shadow-[-8px_0_8px_-8px_rgba(0,0,0,0.25)]",children:"Actions"})]})}),e.jsx(Rs,{children:n!=null&&n.users&&n.users.length>0?n.users.map(s=>{var i,j,g;const t=`${((i=s.firstName)==null?void 0:i[0])??""}${((j=s.lastName)==null?void 0:j[0])??""}`.toUpperCase()||"?",o=((g=s.instagramHandle)==null?void 0:g.replace(/^@/,""))??null;return e.jsxs(te,{"data-testid":`row-user-${s.id}`,children:[e.jsx(x,{children:e.jsxs(Fs,{className:"h-9 w-9","data-testid":`avatar-user-${s.id}`,children:[s.profileImageUrl?e.jsx(Ms,{src:s.profileImageUrl,alt:`${s.firstName??""} ${s.lastName??""}`}):null,e.jsx(Ds,{children:t})]})}),e.jsxs(x,{className:"font-medium",children:[s.firstName," ",s.lastName,s.referredBy?e.jsxs("div",{className:"text-xs text-muted-foreground font-normal","data-testid":`text-referredBy-${s.id}`,children:["Referred by: ",s.referredBy]}
11):null,s.utmSource||s.utmCampaign?e.jsxs("div",{className:"text-xs text-muted-foreground font-normal","data-testid":`text-attribution-${s.id}`,children:["via ",[s.utmSource,s.utmCampaign].filter(Boolean).join("/")]}):null]}),e.jsx(x,{children:s.email}),e.jsx(x,{children:(()=>{const P=(s.socials??[]).filter(v=>v.handle);return P.length===0?o?e.jsxs("a",{href:`https://instagram.com/${o}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm hover:underline","data-testid":`link-instagram-${s.id}`,children:[e.jsx(_s,{className:"w-4 h-4"}),o]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"â"}):e.jsx("div",{className:"flex items-center gap-2","data-testid":`socials-${s.id}`,children:P.map(v=>{const b=Ss[v.platform];if(!b)return null;const B=b.icon,Z=v.handle.replace(/^@/,""),X=v.followerCount!=null?`${b.label}: @${Z} · ${v.followerCount.toLocaleString()} followers`:`${b.label}: @${Z}`;return e.jsx("a",{href:`${b.urlPrefix}${Z}`,target:"_blank",rel:"noopener noreferrer",title:X,"aria-label":X,className:"text-muted-foreground hover:text-foreground transition-colors","data-testid":`link-social-${v.platform}-${s.id}`,children:e.jsx(B,{className:"w-4 h-4"})},v.platform)})})})()}),e.jsx(x,{children:(()=>{var rs;const P=s.topPlatform,v=((rs=s.topFollowerHandle)==null?void 0:rs.replace(/^@/,""))??null,b=s.topFollowerCount;if(!P)return e.jsx("span",{className:"text-sm text-muted-foreground","data-testid":`text-top-follower-empty-${s.id}`,children:"â"});const B=Ss[P],Z=B.icon,X=b!=null?`${B.label}: ${b.toLocaleString()} followers`:`${B.label}: follower count not yet available`,ts=e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm",children:[e.jsx(Z,{className:"w-4 h-4"}),b!=null?e.jsx("span",{className:"font-medium","data-testid":`text-top-follower-count-${s.id}`,children:Ra(b)}):e.jsx("span",{className:"text-muted-foreground","data-testid":`text-top-follower-no-count-${s.id}`,children:"â"})]});return v?e.jsx("a",{href:`${B.urlPrefix}${v}`,target:"_blank",rel:"noopener noreferrer",className:"hover:underline",title:X,"data-testid":`link-top-follower-${s.id}`,children:ts}):e.jsx("span",{title:X,children:ts})})()}),e.jsx(x,{children:e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[Re(s.role||"creator"),(()=>{const P=Js(s.roleGrantedUntil);return P?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground","data-testid":`text-grant-expires-${s.id}`,children:[e.jsx(ns,{className:"w-3 h-3"}),"Expires in ",P]}):null})()]})}),e.jsx(x,{children:s.createdAt?He(new Date(s.createdAt),{addSuffix:!0}):"Unknown"}),e.jsx(x,{className:"text-right sticky right-0 bg-card shadow-[-8px_0_8px_-8px_rgba(0,0,0,0.25)]",children:e.jsxs(oa,{children:[e.jsx(ca,{asChild:!0,children:e.jsx(c,{variant:"ghost",size:"icon","data-testid":`button-user-actions-${s.id}`,children:e.jsx(Aa,{className:"w-4 h-4"})})}),e.jsxs(da,{align:"end",children:[e.jsx(ma,{children:"Actions"}),e.jsx(Le,{}),e.jsxs(he,{onClick:()=>ea(s.id),"data-testid":`button-email-password-${s.id}`,children:[e.jsx(ua,{className:"w-4 h-4 mr-2"}),"Email Password"]}),e.jsxs(he,{onClick:()=>{le(s),we(!0)},"data-testid":`button-reset-password-${s.id}`,children:[e.jsx(Pa,{className:"w-4 h-4 mr-2"}),"Reset Password"]}),e.jsx(Le,{}),e.jsxs(he,{onClick:()=>Ws(s),"data-testid":`button-change-membership-${s.id}`,children:[e.jsx(ha,{className:"w-4 h-4 mr-2"}),"Change Membership"]}),e.jsx(Le,{}),e.jsxs(he,{onClick:()=>{le(s),ve(!0)},className:"text-red-600 hover:text-red-700","data-testid":`button-delete-user-${s.id}`,children:[e.jsx(Fa,{className:"w-4 h-4 mr-2"}),"Delete User"]})]})]})})]},s.id)}):e.jsx(te,{children:e.jsx(x,{colSpan:8,className:"h-32 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx(Ge,{className:"h-12 w-12 text-muted-foreground mb-1"}),e.jsx("h3",{className:"font-medium",children:"No users found"}),C?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground max-w-xs",children:"No user found for that search â they may not have an account yet."}),e.jsxs(c,{size:"sm",onClick:()=>{oe(C.includes("@")?C:""),W(!0)},"data-testid":"button-add-user-empty-state",children:[e.jsx(Be,{className:"w-4 h-4 mr-2"}),"Create Account for This User"]}
11)]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Try adjusting your search or filters"})]})})})})]})}),n&&n.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",(a-1)*De+1," to"," ",Math.min(a*De,n.total)," of ",n.total," users"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>u(s=>Math.max(1,s-1)),disabled:a===1,"data-testid":"button-prev-page",children:[e.jsx(Ma,{className:"w-4 h-4"}),"Previous"]}),e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>u(s=>Math.min(n.totalPages,s+1)),disabled:a===n.totalPages,"data-testid":"button-next-page",children:["Next",e.jsx(xa,{className:"w-4 h-4"})]})]})]})]})]})]});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(ya,{items:Y==="media-coverage-pool"?[{label:"The Festival Academy",href:"/admin/education"},{label:"Media Coverage Priority Pool"}]:[{label:"User Management"}]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold font-heading text-gradient-festival",children:"User Management"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage platform users. Use Export all members for the full active list as a CSV."})]}),e.jsxs(pa,{value:Y,onValueChange:d,className:"space-y-6",children:[e.jsxs(fa,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(os,{value:"users","data-testid":"tab-users",children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),"Users"]}),e.jsxs(os,{value:"media-coverage-pool","data-testid":"tab-media-coverage-pool",children:[e.jsx(ze,{className:"w-4 h-4 mr-2"}),"Media Coverage Pool"]})]}),e.jsx(cs,{value:"users",className:"space-y-6",children:aa}),e.jsx(cs,{value:"media-coverage-pool",className:"space-y-6",children:e.jsx($a,{})})]}),e.jsx(ds,{open:qs,onOpenChange:s=>{W(s),s||(oe(""),be(""),Ce(""),Se(""),Te("creator"))},children:e.jsxs(ms,{children:[e.jsxs(us,{children:[e.jsx(hs,{children:"Create User Account"}),e.jsx(xs,{children:'Create a new account so a creator can log in. Send them their password separately, or use "Email Password Reset" after creating the account.'})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{htmlFor:"create-user-email",children:"Email *"}),e.jsx(F,{id:"create-user-email",type:"email",placeholder:"[email protected]",value:ne,onChange:s=>oe(s.target.value),"data-testid":"input-create-user-email"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{htmlFor:"create-user-password",children:"Password * (min. 8 characters)"}),e.jsx(F,{id:"create-user-password",type:"password",placeholder:"Temporary password",value:L,onChange:s=>be(s.target.value),"data-testid":"input-create-user-password"}),L.length>0&&L.length<8&&e.jsx("p",{className:"text-sm text-destructive",children:"Password must be at least 8 characters"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{htmlFor:"create-user-first",children:"First Name"}),e.jsx(F,{id:"create-user-first",placeholder:"First",value:Ze,onChange:s=>Ce(s.target.value),"data-testid":"input-create-user-firstName"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{htmlFor:"create-user-last",children:"Last Name"}),e.jsx(F,{id:"create-user-last",placeholder:"Last",value:Xe,onChange:s=>Se(s.target.value),"data-testid":"input-create-user-lastName"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{htmlFor:"create-user-role",children:"Role"}),e.jsxs(K,{value:es,onValueChange:s=>Te(s),children:[e.jsx(Q,{id:"create-user-role","data-testid":"select-create-user-role",children:e.jsx(H,{})}),e.jsx(G,{children:Ve.map(s=>e.jsx(m,{value:s.value,children:s.label},s.value))})]})]})]}),e.jsxs(ps,{children:[e.jsx(c,{variant:"outline",onClick:()=>W(!1),children:"Cancel"}),e.jsx(c,{onClick:Gs,disabled:$e.isPending||!ne||L.length<8,"data-testid":"button-create-user-submit",children:$e.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}),"Creatingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-4 h-4 mr-2"}),"Create Account"]})})]})]})}),e.jsx(fs,{open:Bs,onOpenChange:ve,children:e.jsxs(js,{children:[e.jsxs(gs,{children:[e.jsx(vs,{children:"Delete User"}),e.jsxs(ws,{children:["Are you sure you want to delete ",h==null?void 0:h.firstName," ",h==null?void 0:h.lastName,"? This action cannot be undone."]})]}),e.jsxs(Ns,{children:[e.jsx(ys,{children:"Cancel"}),e.jsx(bs,{onClick:()=>h&&Hs.mutate(h.id),className:"bg-red-600 hover:bg-red-700",children:"Delete"})]})]})}),e.jsx(fs,{open:Vs,onOpenChange:we,children:e.jsxs(js,{children:[e.jsxs(gs,{children:[e.jsx(vs,{children:"Reset Password"}),e.jsxs(ws,{children:["Enter a new password for ",h==null?void 0:h.firstName," ",h==null?void 0:h.lastName]})]}),e.jsxs("div",{className:"py-4 space-y-2",children:[e.jsx(F,{type:"password",placeholder:"Enter new password (min. 8 characters)",value:k,onChange:s=>Ne(s.target.value),"data-testid":"input-new-password"}),k.length>0&&k.length<8&&e.jsx("p",{className:"text-sm text-destructive","data-testid":"text-password-too-short",children:"Password must be at least 8 characters."})]}),e.jsxs(Ns,{children:[e.jsx(ys,{onClick:()=>Ne(""),children:"Cancel"}),e.jsx(bs,{onClick:sa,disabled:!k||k.length<8||_e.isPending,children:_e.isPending?"Resettingâ¦":"Reset Password"})]})]})}),e.jsx(ds,{open:zs,onOpenChange:s=>{ce(s),s||ke(null)},children:e.jsxs(ms,{className:"sm:max-w-lg","data-testid":"dialog-change-membership",children:[e.jsxs(us,{children:[e.jsx(hs,{children:"Change membership"}),e.jsxs(xs,{children:["Assign"," ",e.jsxs("span",{className:"font-medium text-foreground",children:[y==null?void 0:y.firstName," ",y==null?void 0:y.lastName]})," ","to a membership tier. Optionally set an expiration so the change automatically reverts after the peri
11od ends."]})]}),e.jsxs("div",{className:"space-y-5 py-2",children:[y&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 rounded-md border bg-muted/30 px-3 py-2.5","data-testid":"preview-membership-change",children:[e.jsx("span",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Current"}),Re(y.role||"creator"),e.jsx(ja,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"New"}),Re(Ae)]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"membership-role-select",children:"Membership tier"}),e.jsxs(K,{value:Ae,onValueChange:s=>ss(s),children:[e.jsx(Q,{id:"membership-role-select",className:"h-auto py-2.5 [&>span]:flex [&>span]:flex-1","data-testid":"select-membership-role",children:e.jsx(H,{placeholder:"Select a tier"})}),e.jsx(G,{children:M.map(s=>{const t=s.icon;return e.jsx(m,{value:s.value,"data-testid":`option-membership-role-${s.value}`,children:e.jsxs("div",{className:"flex items-start gap-2.5 text-left",children:[e.jsx(t,{className:`w-4 h-4 mt-0.5 shrink-0 ${s.iconClass}`}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.description})]})]})},s.value)})})]})]}),N?e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"Duration"}),e.jsxs(wa,{value:de,onValueChange:s=>Pe(s),className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsxs(w,{htmlFor:"duration-permanent",className:"flex items-start gap-3 rounded-md border bg-card p-3 hover-elevate cursor-pointer transition-colors [&:has([data-state=checked])]:border-primary [&:has([data-state=checked])]:bg-primary/5",children:[e.jsx(Cs,{id:"duration-permanent",value:"permanent",className:"mt-0.5","data-testid":"radio-duration-permanent"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-medium",children:[e.jsx(Ea,{className:"w-4 h-4 text-primary"}),"Permanent"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Stays in this tier until you change it."})]})]}),e.jsxs(w,{htmlFor:"duration-temporary",className:"flex items-start gap-3 rounded-md border bg-card p-3 hover-elevate cursor-pointer transition-colors [&:has([data-state=checked])]:border-primary [&:has([data-state=checked])]:bg-primary/5",children:[e.jsx(Cs,{id:"duration-temporary",value:"temporary",className:"mt-0.5","data-testid":"radio-duration-temporary"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-medium",children:[e.jsx(Da,{className:"w-4 h-4 text-primary"}),"Time-limited"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Reverts after the period ends."})]})]})]})]}):e.jsx("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-xs text-muted-foreground","data-testid":"notice-permanent-only",children:"Time-limited grants are reserved for admins. This change will be permanent."}),N&&de==="temporary"&&e.jsxs("div",{className:"space-y-3 rounded-md border bg-muted/30 p-3",children:[e.jsxs("div",{children:[e.jsx(w,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Quick presets"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:Ia.map(s=>{const t=A===s.value&&me===s.unit;return e.jsx(c,{type:"button",size:"sm",variant:t?"default":"outline",onClick:()=>{Fe(s.value),Me(s.unit)},"data-testid":`button-duration-preset-${s.value}-${s.unit}`,children:s.label},s.label)})})]}),e.jsxs("div",{children:[e.jsx(w,{htmlFor:"membership-duration-value",className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Custom length"}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsx(F,{id:"membership-duration-value",type:"number",min:1,max:365,value:A,onChange:s=>Fe(Number(s.target.value)||0),className:"w-24","data-testid":"input-membership-duration"}),e.jsxs(K,{value:me,onValueChange:s=>Me(s),children:[e.jsx(Q,{className:"w-32","data-testid":"select-membership-duration-unit",children:e.jsx(H,{})}),e.jsxs(G,{children:[e.jsx(m,{value:"days",children:"Days"}),e.jsx(m,{value:"weeks",children:"Weeks"}),e.jsx(m,{value:"months",children:"Months"})]})]})]})]}),as&&e.jsxs("p",{className:"flex items-center gap-1.5 rounded-sm bg-background/60 px-2 py-1.5 text-xs text-muted-foreground","data-testid":"text-membership-expires-preview",children:[e.jsx(ns,{className:"w-3.5 h-3.5 text-primary"}),"Reverts on"," ",e.jsx("span",{className:"font-medium text-foreground",children:as.toLocaleStr
11ing(void 0,{dateStyle:"medium",timeStyle:"short"})})]})]})]}),e.jsxs(ps,{children:[e.jsx(c,{variant:"outline",onClick:()=>ce(!1),"data-testid":"button-membership-cancel",children:"Cancel"}),e.jsx(c,{onClick:Zs,disabled:Ie.isPending,"data-testid":"button-membership-save",children:Ie.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}),"Savingâ¦"]}):"Save membership"})]})]})})]})}export{ft 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.