1import{u as A,r as o,j as e}from"./vendor-react-BoyrKzsG.js";import{u as P,f as R,e as g,D as B,o as D,n as L}from"./index-CKCEYSTE.js";import{g as O,a as F}from"./communityService-CSdb11lr.js";import{isMember as _}from"./membershipService-Dm6bLb_P.js";import{P as $}from"./PageHeader-D3Dh_hTn.js";/* empty css */import{y as W,u as Y,r as C}from"./vendor-ui-Cy9YOY35.js";import"./vendor-firebase-DbFCdLkQ.js";const ee=()=>{const m=A(),{user:i,userProfile:c,isAdmin:h}=P(),[n,l]=o.useState("all"),[y,f]=o.useState([]),[j,v]=o.useState([]),[N,d]=o.useState(!0),[b,E]=o.useState({}),[S,T]=o.useState(!1),U=R();o.useEffect(()=>{w()},[i]);const w=async()=>{if(i){d(!0);try{const s=await g.canCreateCommunity(i.uid);T(s.allowed);const a=await O({limit:100}),r=B.map(t=>t.id),p=a.filter(t=>!r.includes(t.id));f(p);const I=(await F(i.uid)).filter(t=>!r.includes(t.id));v(I);const x={};for(const t of p){const z=await _(t.id,i.uid);x[t.id]=z}E(x)}catch(s){console.error("Error loading communities:",s)}finally{d(!1)}}},M=async()=>{var a;if(!i)return;console.log("[USER-CREATED-COMMUNITIES] Checking creation permissions...");const s=await g.canCreateCommunity(i.uid);if(s.allowed)m("/communities/create/");else{console.log("[USER-CREATED-COMMUNITIES] Creation blocked:",s.reason);const r=((a=c==null?void 0:c.subscription)==null?void 0:a.tier)||"free";!h&&r!=="pro"?U.show({feature:"Community Creation",description:s.reason||"Pro users can lead their own private communities. Upgrade to start your own community!",suggestedTier:"pro",source:"user_created_communities",featureIcon:"pro"}):L.error(s.reason||"You've reached your community creation limit.")}},k=s=>{m(`/communities/${s}`,{state:{from:"user-created"}})},u=n==="all"?y:j;return N?e.jsx("div",{className:"communities-page",children:e.jsx(D,{message:"Finding communities..."})}):e.jsxs("div",{className:"communities-page",children:[e.jsxs("header",{className:"communities-hero",style:{paddingTop:"8px"},children:[e.jsx($,{title:"User Created",subtitle:"Communities built by our members",renderRight:S&&e.jsx("button",{className:"create-community-circle-btn",onClick:M,"aria-label":"Create Community",children:e.jsx(W,{size:22,strokeWidth:3})}),showBack:!0,onBack:()=>m("/communities/")}),e.jsxs("div",{className:"category-scroll",style:{marginTop:"12px"},children:[e.jsx("button",{className:`category-pill ${n==="all"?"active":""}`,onClick:()=>l("all"),children:"Explore All"}),e.jsx("button",{className:`category-pill ${n==="my"?"active":""}`,onClick:()=>l("my"),children:"My Communities"})]})]}),e.jsx("div",{className:"communities-content",style:{paddingBottom:"80px"},children:e.jsx("div",{className:"communities-list",children:u.length===0?e.jsxs("div",{className:"empty-results",style:{marginTop:"40px"},children:[e.jsx(Y,{size:48,className:"empty-icon"}),e.jsx("p",{children:n==="all"?"No user-created communities yet.":"You haven't joined any communities yet."}),e.jsx("span",{style:{fontSize:"14px",color:"#999",marginTop:"8px"},children:n==="all"?"Be the first to lead one!":"Explore and find your tribe."})]}):u.map(s=>{var a,r;return e.jsxs("div",{className:"community-list-item is-user-created",onClick:()=>k(s.id),children:[e.jsx("div",{className:"item-icon",style:{position:"relative",overflow:"hidden"},children:s.imageUrl?e.jsx("img",{src:s.imageUrl,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}}):e.jsx(C,{size:24})}),e.jsxs("div",{className:"item-content",children:[e.jsxs("div",{className:"item-main",children:[e.jsx("h3",{className:"item-name",children:s.name}),e.jsxs("span",{className:"member-badge",children:[e.jsx(C,{size:12}),((a=s.statistics)==null?void 0:a.memberCount)||0]})]}),e.jsx("p",{className:"item-description",children:s.description}),e.jsxs("div",{style:{marginTop:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{className:"category-tag",style:{fontSize:"9px",padding:"2px 8px"},children:(r=s.category)==null?void 0:r.struggleCategory}),b[s.id]&&e.jsx("span",{style:{fontSize:"10px",color:"#10B981",fontWeight:700,textTransform:"uppercase"},children:"Joined"})]})]})]},s.id)})})})]})};export{ee 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.