PageSourceSearch

https://mindgolf.ai/assets/AdminUserManagement-CstW8Psc.js

js mindgolf.ai collected 2026-10-05 14:52:48 UTC 22,509 bytes, 1 lines download raw bytes

1import{r as d,j as e,n as Ke}from"./vendor-ahVw9cdH.js";import{O as n,a5 as Qe,a6 as Ge,a7 as v,eu as we,bM as Ze,V as E,bZ as He,fc as Ae,c2 as F,c3 as D,c4 as P,c5 as q,c6 as l,a3 as me,af as We,aw as re,ds as Ne,ft as ae,f2 as C,bA as i,bl as Xe,bm as Ye,bo as Je,am as es,az as ss,R as te,bN as ie,bP as ne,bQ as oe,bR as ce,bS as le,bT as de,bU as ue,bV as xe,cf as rs,Y as as,bz as ts,aX as Se,dU as is}from"./index-DXi0I5ak.js";import{u as Q}from"./query-CeIq2NOR.js";import{C as ns,a as os,b as cs,c as ls,d as ds,e as us}from"./command-CK_xWGRQ.js";import{Z as xs}from"./zap-FPBcTry6.js";import{R as Ce}from"./rocket-TSTWgVwM.js";import{B as ms}from"./BetaTesterManager-CHA1O7OQ.js";import{A as hs}from"./AppBreadcrumb-DQQeh5xA.js";import"./radix--pSzM2y8.js";import"./supabase-DYrB2Yg5.js";import"./charts-CSweoJhv.js";import"./forms-Cc1FL3tT.js";import"./circle-check-big-BdhKg125.js";import"./circle-x-gCUm4_Za.js";import"./user-check-BZoKlDGY.js";import"./breadcrumb-C59QT_kB.js";const ps=({user:a,onRoleChange:f})=>{var he,pe,ge,fe,je,ye,ve,_e,be;const[b,A]=d.useState(""),[Y,k]=d.useState(!1),[O,j]=d.useState(null),[J,G]=d.useState(!1),[L,U]=d.useState(!1),[o,c]=d.use
1State(!1),[u,x]=d.useState(!1),[h,T]=d.useState(!1),[B,Z]=d.useState(!1),[$,H]=d.useState(""),[w,V]=d.useState(""),[M,m]=d.useState("coach"),[z,R]=d.useState(!1),{data:p}=Q({queryKey:["admin-all-b2b-orgs"],queryFn:async()=>{const{data:s,error:r}=await n.from("organizations").select("id, name, type").in("type",["federation","academy","coach"]).order("name");return r?[]:s||[]}}),{data:g,refetch:y}=Q({queryKey:["user-org-memberships",a.id],queryFn:async()=>{const{data:s,error:r}=await n.from("organization_members").select("id, role, organization_id").eq("user_id",a.id);if(r||!(s!=null&&s.length))return[];const t=s.map(K=>K.organization_id),[{data:_},{data:N}]=await Promise.all([n.from("organizations").select("id, name, slug, type").in("id",t),n.from("organization_subscriptions").select("id, organization_id, tier, status").in("organization_id",t)]);return s.map(K=>{const S=_==null?void 0:_.find(se=>se.id===K.organization_id),I=N==null?void 0:N.find(se=>se.organization_id===K.organization_id);return{...K,org_name:(S==null?void 0:S.name)||"Unknown",org_slug:(S==null?void 0:S.slug)||"",org_tier:(I==null?void 0:I.tier)||null,org_sub_id:(I==null?void 0:I.id)||null,org_type:(S==null?void 0:S.type)??null}})}}),{data:ee}=Q({queryKey:["user-org-players",a.id],queryFn:async()=>{const{data:s,error:r}=await n.from("organization_players").select("id, organization_id").eq("player_id",a.id);return r?[]:s||[]}}),{data:ke}=Q({queryKey:["user-beta-tester",a.email],queryFn:async()=>{const{data:s,error:r}=await n.from("beta_testers").select("id, status, is_early_access").eq("email",a.email.toLowerCase()).eq("status","accepted").eq("is_early_access",!0).maybeSingle();return r?null:s}}),ze=((g==null?void 0:g.length)||0)>0,Ee=((ee==null?void 0:ee.length)||0)>0,Re=ze||Ee,Fe=s=>{switch(s){case"super_admin":return e.jsx(as,{className:"h-3 w-3"});case"admin":return e.jsx(rs,{className:"h-3 w-3"});default:return e.jsx(me,{className:"h-3 w-3"})}},De=s=>{switch(s){case"super_admin":return"default";case"admin":return"secondary";default:return"outline"}},Pe=async()=>{if(!b){i.error("Please select a role");return}if(a.roles.includes(b)){i.error("User already has this role");return}try{const s={user_id:a.id,role:b},{error:r}=await n.from("user_roles").insert(s);if(r)throw r;i.success(`${b} role assigned to ${a.name}`),A(""),k(!1),f()}catch(s){console.error("Error adding role:",s),i.error("Failed to assign role")}},qe=async s=>{try{const{error:r}=await n.from("user_roles").delete().eq("user_id",a.id).eq("role",s);if(r)throw r;i.success(`${s} role revoked from ${a.name}`),j(null),f()}catch(r){console.error("Error revoking role:",r),i.error("Failed to revoke role")}},Oe=async s=>{G(!0);try{const r=a.subscription;if(s==="free"){if(r){const{error:t}=await n.from("user_subscriptions").update({status:"canceled",tier:"free"}).eq("user_id",a.id);if(t)throw t}i.success(`${a.name} set to Free tier`)}else{if(r){const{error:t}=await n.from("user_subscriptions").update({tier:"unlimited",status:"active",billing_interval:null,source:"admin_grant",updated_at:new Date().toISOString()}).eq("user_id",a.id);if(t)throw t}else{const{error:t}=await n.from("user_subscriptions").insert({user_id:a.id,tier:"unlimited",status:"active",billing_interval:null,source:"admin_grant"});if(t)throw t}i.success(`${a.name} upgraded to Pro tier`)}f()}catch(r){console.error("Error updating subscription tier:",r),i.error("Failed to update subscription tier")}finally{G(!1)}},Ue=async(s,r)=>{try{const{error:t}=await n.rpc("admin_set_organization_type",{p_org_id:s.organization_id,p_new_type:r});if(t)throw t;i.success(`${s.org_name} type updated to ${r}`),y(),f()}catch(t){console.error("Error updating org type:",t),i.error("Failed to update organization type")}},Be=async(s,r)=>{var t;try{const _={coach:ae.coach.includedPlayers};if(s.org_sub_id){const{error:N}=await n.from("organization_subscriptions").update({tier:r,player_limit:_[r]||15,status:"active",updated_at:new Date().toISOString()}).eq("id",s.org_sub_id);if(N)throw N}else{const{error:N}=await n.from("organization_subscriptions").insert({organization_id:s.organization_id,tier:r,player_limit:_[r]||15,status:"active"});if(N)throw N}i.success(`${s.org_name} tier updated to ${((t=ae[r])==null?void 0:t.name)||r}`),y()}catch(_){console.error("Error updating org tier:",_),i.error("Failed to update organization tier")}},Ie=async()=>{c(!0);try{const{error:s}=await n.functions.invoke("admin-delete-user",{body:{userId:a.id}});if(s)throw s;i.success(`${a.name} has been permanently deleted`),U(!1),f()}catch(s){console.error("Error deleting user:",s),i.error("Failed to delete user")}finally{c(!1)}},W=((he=a.subscription)==null?void 0:he.tier)==="unlimited"||((pe=a.subscription)==null?void 0:pe.tier)==="pro",X=((ge=a.subscription)==null?void 0:ge.status)==="active",Le=!!ke&&!(W&&X&&((fe=a.subscription)==null?void 0:fe.source)==="early_access"),Te=W&&X&&((je=a.subscription)==null?void 0:je.source)==="early_access",$e=async()=>{T(!0);try{const s=new Date;s.setDate(s.getDate()+60);const r=s.toISOString(),{error:t}=await n.from("user_subscriptions").upsert({user_id:a.id,tier:"unlimited",status:"active",source:"early_access",billing_interval:"monthly",current_period_end:r},{onConflict:"user_id"});if(t)throw t;await n.from("notifications").insert({user_id:a.id,type:"early_access_activated",category:"achievement",title:"Early Access Pro Activated! 🎉",message:"Your 2 months of free Pro access have been activated. Enjoy all premium features!",action_url:"/dashboard"}),i.success(`Early Access Pro activated for ${a.name}`),x(!1),f()}catch(s){console.error("Error activating early access:",s),i.error("Failed to activate early access")}finally{T(!1)}},Ve=async()=>{var s;if(!w){i.error("Please select an organization");return}if(g!=null&&g.some(r=>r.organization_id===w)){i.error("User is already a member of this organization");return}R(!0);try{const{error:r}=await n.from("organization_members").insert({organization_id:w,user_id:a.id,role:M});if(r)throw r;const t=((s=p==null?void 0:p.find(_=>_.id===w))==null?void 0:s.name)||"organization";i.success(`${a.name} added to ${t}`),V(""),m("coach"),y()}catch(r){console.error("Error adding to org:",r),i.error((r==null?void 0:r.message)||"Failed to add to organization")}finally{R(!1)}},Me=s=>
1{switch(s){case"early_access":return"Early Access";case"stripe":return"Stripe";case"admin_grant":return"Admin";case"referral":return"Referral";default:return s||"Unknown"}};return e.jsxs(e.Fragment,{children:[e.jsx(Qe,{children:e.jsx(Ge,{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("h3",{className:"text-sm font-semibold truncate",children:a.name}),Re?e.jsxs(v,{variant:"outline",className:"text-[10px] px-1.5 py-0 flex items-center gap-0.5 shrink-0",children:[e.jsx(we,{className:"h-2.5 w-2.5"}),"B2B"]}):e.jsx(v,{variant:"outline",className:"text-[10px] px-1.5 py-0 shrink-0",children:"B2C"}),a.round_count>0&&e.jsxs(v,{variant:"secondary",className:"text-[10px] px-1.5 py-0 shrink-0",children:[a.round_count," ",a.round_count===1?"round":"rounds"]}),a.signup_type==="beta"&&e.jsxs(v,{variant:"outline",className:"text-[10px] px-1.5 py-0 shrink-0 border-orange-300 text-orange-700 dark:border-orange-700 dark:text-orange-400 flex items-center gap-0.5",children:[e.jsx(Ze,{className:"h-2.5 w-2.5"}),"Beta"]}),a.signup_type==="early_access"&&e.jsxs(v,{variant:"outline",className:"text-[10px] px-1.5 py-0 shrink-0 border-emerald-300 text-emerald-700 dark:border-emerald-700 dark:text-emerald-400 flex items-center gap-0.5",children:[e.jsx(xs,{className:"h-2.5 w-2.5"}),"Early Access"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:a.email})]}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive hover:bg-destructive/10 shrink-0",onClick:()=>U(!0),disabled:o,children:e.jsx(He,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-1.5 px-2 rounded-md bg-muted/40",children:[W&&X?e.jsxs(e.Fragment,{children:[e.jsxs(v,{className:"bg-gradient-to-r from-violet-600 to-purple-600 text-white text-[10px] px-1.5 py-0 flex items-center gap-0.5",children:[e.jsx(Ae,{className:"h-2.5 w-2.5"}),"Pro"]}),e.jsx(v,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:Me(((ye=a.subscription)==null?void 0:ye.source)??null)}),((ve=a.subscription)==null?void 0:ve.current_period_end)&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["expires ",new Date(a.subscription.current_period_end).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]}),!((_e=a.subscription)!=null&&_e.current_period_end)&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"no end date"})]}):e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Free plan"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[Le&&!Te&&e.jsxs(E,{size:"sm",variant:"outline",className:"h-6 text-[10px] px-1.5 border-emerald-500/30 text-emerald-700 dark:text-emerald-400 hover:bg-emerald-500/10",onClick:()=>x(!0),children:[e.jsx(Ce,{className:"h-2.5 w-2.5 mr-0.5"}),"EA"]}),e.jsxs(F,{value:W&&X?"pro":"free",onValueChange:Oe,disabled:J,children:[e.jsx(D,{className:"w-[72px] h-6 text-[10px]",children:e.jsx(P,{})}),e.jsxs(q,{children:[e.jsx(l,{value:"free",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(me,{className:"h-3 w-3"}),"Free"]})}),e.jsx(l,{value:"pro",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(We,{className:"h-3 w-3"}),"Pro"]})})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.roles.length===0&&e.jsx(v,{variant:"outline",className:"text-[10px]",children:"No roles"}),a.roles.map(s=>e.jsxs(v,{variant:De(s),className:"flex items-center gap-0.5 text-[10px]",children:[Fe(s),s,e.jsx("button",{onClick:()=>j(s),className:"ml-0.5 hover:text-destructive",children:e.jsx(re,{className:"h-2.5 w-2.5"})})]},s))]}),e.jsx("div",{className:"shrink-0",children:Y?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(F,{value:b,onValueChange:A,children:[e.jsx(D,{className:"w-[100px] h-6 text-[10px]",children:e.jsx(P,{placeholder:"Select"})}),e.jsxs(q,{children:[e.jsx(l,{value:"user",children:"User"}),e.jsx(l,{value:"admin",children:"Admin"}),e.jsx(l,{value:"super_admin",children:"Super Admin"})]})]}),e.jsx(E,{size:"sm",className:"h-6 text-[10px] px-1.5",onClick:Pe,children:"Add"}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-6 text-[10px] px-1.5",onClick:()=>{k(!1),A("")},children:e.jsx(re,{className:"h-3 w-3"})})]}):e.jsxs(E,{size:"sm",variant:"ghost",className:"h-6 text-[10px] px-1.5",onClick:()=>k(!0),children:[e.jsx(Ne,{className:"h-3 w-3 mr-0.5"}),"Role"]})})]}),e.jsxs("div",{className:"pt-2 border-t space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(we,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:"Organizations"})]}),g&&g.length>0?e.jsx("div",{className:"flex flex-col gap-1.5",children:g.map(s=>e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx(v,{variant:"outline",className:"text-[10px]",children:s.org_name}),e.jsxs(F,{value:s.org_type||"coach",onValueChange:r=>Ue(s,r),children:[e.jsx(D,{className:"w-[100px] h-5 text-[10px]",children:e.jsx(P,{})}),e.jsxs(q,{children:[e.jsx(l,{value:"federation",children:"Coach Licensing"}),e.jsx(l,{value:"academy",children:"Academy"}),e.jsx(l,{value:"coach",children:"Coach"})]})]}),e.jsxs(F,{value:s.org_tier||"coach",onValueChange:r=>Be(s,r),children:[e.jsx(D,{className:"w-[90px] h-5 text-[10px]",children:e.jsx(P,{})}),e.jsx(q,{children:e.jsx(l,{value:"coach",children:ae.coach.name})})]}),e.jsxs(F,{value:s.role,onValueChange:async r=>{try{const{error:t}=await n.from("organization_members").update({role:r}).eq("id",s.id);if(t)throw t;i.success(`Org role updated to ${C[r]||r}`),y()}catch{i.error("Failed to update org role")}},children:[e.jsx(D,{className:"w-[80px] h-5 text-[10px]",children:e.jsx(P,{})}),e.jsxs(q,{children:[e.jsx(l,{value:"owner",children:C.owner}),e.jsx(l,{value:"admin",children:C.admin}),e.jsx(l,{value:"coach",children:C.coach}),e.jsx(l,{value:"viewer",children:C.viewer})]})]}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0 text-muted-foreground hover:text-destructive",onClick:async()=>{try{const{error:r}=await n.from("organization_members").delete().eq("id",s.id);if(r)throw r;i.success("Removed from organization"),y()}catch{i.error("Failed to remove from organization")}},children:e.jsx(re,{className:"h-2.5 w-2.5"})})]},s.id))}):e.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Not a member of any organization"}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap pt-1",children:[e.jsxs(Xe,{open:B,onOpenChange:Z,children:[e.jsx(Ye,{asChild:!0,children:e.jsxs(E,{variant:"outline",size:"sm",role:"combobox","aria-expanded":B,className:"h-6 text-[10px] px-2 justify-between min-w-[180px]",children:[w?(be=p==null?void 0:p.find(s=>s.id===w))==null?void 0:be.name:"Select organization...",e.jsx(Ne,{className:"h-3 w-3 opacity-50"})]})}),e.jsx(Je,{className:"w-[260px] p-0",align:"start",children:e.jsxs(ns,{children:[e.jsx(os,{placeholder:"Search organizations...",value:$,onValueChange:H,className:"h-8 text-xs"}),e.jsxs(cs,{children:[e.jsx(ls,{children:"No organization found."}),e.jsx(ds,{children:p==null?void 0:p.map(s=>e.jsxs(us,{value:`${s.name} ${s.type}`,onSelect:()=>{V(s.id),Z(!1)},className:"text-xs",children:[e.jsx(es,{className:ss("mr-2 h-3 w-3",w===s.id?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1 truncate",children:s.name}),e.jsx(v,{variant:"outline",className:"ml-2 text-[9px] px-1 py-0",children:s.type})]},s.id))})]})]})})]}),e.jsxs(F,{value:M,onValueChange:m,children:[e.jsx(D,{className:"w-[90px] h-6 text-[10px]",children:e.jsx(P,{})}),e.jsxs(q,{children:[e.jsx(l,{value:"owner",children:C.owner}),e.jsx(l,{value:"admin",children:C.admin}),e.jsx(l,{value:"coach",children:C.coach}),e.jsx(l,{value:"viewer",children:C.viewer})]})]}),e.jsx(E,{size:"sm",className:"h-6 text-[10px] px-2",onClick:Ve,disabled:!w||z,children:z?e.jsx(te,{className:"h-3 w-3 animate-spin"}):"Add"})]})]})]})})}),e.jsx(ie,{open:!!O,onOpenChange:()=>j(null),children:e.jsxs(ne,{children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Revoke Role"}),e.jsxs(le,{children:["Are you sure you want to revoke the ",e.jsx("strong",{children:O})," role from ",e.jsx("strong",{children:a.name}),"? This action cannot be undone."]})]}),e.jsxs(de,{children:[e.jsx(ue,{children:"Cancel"}),e.jsx(xe,{onClick:()=>O&&qe(O),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Revoke Role"})]})]})}),e.jsx(ie,{open:L,onOpenChange:U,children:e.jsxs(ne,{children:[e.jsxs(oe,{children:[e.jsx(ce,{className:"text-destructive",children:"Permanently Delete User"}),e.jsxs(le,{className:"space-y-2",children:[e.jsxs("p",{children:["Are you sure you want to permanently delete ",e.jsx("strong",{children:a.name})," (",a.email,")?"]}),e.jsx("p",{className:"font-semibold text-destructive",children:"This action is irreversible. All user data, rounds, subscriptions, and associated records will be permanently removed."})]})]}),e.jsxs(de,{children:[e.jsx(ue,{disabled:o,children:"Cancel"}),e.jsx(xe,{onClick:Ie,disabled:o,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:o?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete Permanently"})]})]})}),e.jsx(ie,{open:u,onOpenChange:x,children:e.jsxs(ne,{children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Activate Early Access Pro"}),e.jsxs(le,{children:["This will grant ",e.jsx("strong",{children:a.name})," (",a.email,") 2 months of free Pro access as an early access beta tester. The subscription will expire 60 days from now."]})]}),e.jsxs(de,{children:[e.jsx(ue,{disabled:h,children:"Cancel"}),e.jsx(xe,{onClick:$e,disabled:h,children:h?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"h-4 w-4 mr-2 animate-spin"}),"Activating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ce,{className:"h-4 w-4 mr-2"}),"Activate Pro"]})})]})]})})]})};function Fs(){const a=Ke(),{isSuperAdmin:f,isLoading:b}=ts(),[A,Y]=d.useState(""),[k,O]=d.useState("all"),{data:j,isLoading:J,refetch:G}=Q({queryKey:["admin-users"],queryFn:async()=>{var V,M;const{data:o,error:c}=await n.from("profiles").select("id, name, email, created_at").order("created_at",{ascending:!1});if(c)throw c;const{data:u,error:x}=await n.from("user_roles").select("user_id, role");
1if(x)throw x;const{data:h,error:T}=await n.from("user_subscriptions").select("user_id, tier, status, source, current_period_end");if(T)throw T;const[B,Z]=await Promise.all([n.from("rounds").select("player_id"),n.from("beta_testers").select("email, status, is_early_access")]);if(B.error)throw B.error;const $={};(V=B.data)==null||V.forEach(m=>{$[m.player_id]=($[m.player_id]||0)+1});const H={};return(M=Z.data)==null||M.forEach(m=>{H[m.email.toLowerCase()]={status:m.status,is_early_access:m.is_early_access}}),o.map(m=>{var g;const z=h.find(y=>y.user_id===m.id),R=H[(g=m.email)==null?void 0:g.toLowerCase()];let p="standard";return R&&(R.status==="invited"||R.status==="accepted")&&(p=R.is_early_access?"early_access":"beta"),{...m,roles:u.filter(y=>y.user_id===m.id).map(y=>y.role),subscription:z?{tier:z.tier,status:z.status,source:z.source,current_period_end:z.current_period_end}:null,round_count:$[m.id]||0,signup_type:p}})},enabled:f});d.useEffect(()=>{!b&&!f&&(i.error("Access denied. Super admin privileges required."),a("/"))},[f,b,a]);const L=d.useMemo(()=>{if(!j)return{total:0,pro:0,free:0};const o=j.filter(c=>{var u,x,h;return(((u=c.subscription)==null?void 0:u.tier)==="unlimited"||((x=c.subscription)==null?void 0:x.tier)==="pro")&&((h=c.subscription)==null?void 0:h.status)==="active"}).length;return{total:j.length,pro:o,free:j.length-o}},[j]),U=d.useMemo(()=>{let o=j||[];if(A){const c=A.toLowerCase();o=o.filter(u=>u.name.toLowerCase().includes(c)||u.email.toLowerCase().includes(c))}return k==="pro"?o=o.filter(c=>{var u,x,h;return(((u=c.subscription)==null?void 0:u.tier)==="unlimited"||((x=c.subscription)==null?void 0:x.tier)==="pro")&&((h=c.subscription)==null?void 0:h.status)==="active"}):k==="free"&&(o=o.filter(c=>{var u,x,h;return!((((u=c.subscription)==null?void 0:u.tier)==="unlimited"||((x=c.subscription)==null?void 0:x.tier)==="pro")&&((h=c.subscription)==null?void 0:h.status)==="active")})),o},[j,A,k]);return b||J?e.jsxs("div",{className:"space-y-4",children:[e.jsx(Se,{className:"h-12 w-3/4"}),e.jsx(Se,{className:"h-96 w-full"})]}):f?e.jsxs("div",{className:"space-y-4",children:[e.jsx(hs,{items:[{label:"Home",href:"/dashboard"},{label:"Admin",href:"/admin"},{label:"User Management"}]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(is,{className:"h-6 w-6"}),"User Management"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage users, roles, and beta testers"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"rounded-md border bg-card p-2 text-center",children:[e.jsx("p",{className:"text-lg font-bold tabular-nums",children:L.total}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total"})]}),e.jsxs("div",{className:"rounded-md border bg-card p-2 text-center",children:[e.jsx("p",{className:"text-lg font-bold tabular-nums text-violet-600 dark:text-violet-400",children:L.pro}),e.jsxs("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider flex items-center justify-center gap-0.5",children:[e.jsx(Ae,{className:"h-2.5 w-2.5"})," Pro"]})]}),e.jsxs("div",{className:"rounded-md border bg-card p-2 text-center",children:[e.jsx("p",{className:"text-lg font-bold tabular-nums",children:L.free}),e.jsxs("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider flex items-center justify-center gap-0.5",children:[e.jsx(me,{className:"h-2.5 w-2.5"})," Free"]})]})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsx(ms,{})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Search name or email...",value:A,onChange:o=>Y(o.target.value),className:"flex-1 px-3 py-1.5 rounded-md border bg-background text-sm"}),e.jsxs(F,{value:k,onValueChange:o=>O(o),children:[e.jsx(D,{className:"w-[90px] h-9 text-xs",children:e.jsx(P,{})}),e.jsxs(q,{children:[e.jsx(l,{value:"all",children:"All"}),e.jsx(l,{value:"pro",children:"Pro"}),e.jsx(l,{value:"free",children:"Free"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[U.map(o=>e.jsx(ps,{user:o,onRoleChange:()=>G()},o.id)),U.length===0&&e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No users found"})]})]}):null}export{Fs 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.