1import{e as V,r as h,a as y,b as e,k as S,t as p,h as k,n as E,F as G,l as O,s as ie,o as c,c as J,A as le,v as ce,u as de,Q as ue,w as me,f as ye,p as H,i as fe,K as Q}from"./vendor-D3ahWMFY.js";import{p as X,q as Y,s as Z,_ as D,u as ee,a as N,C as ge}from"./index-YqUjisW-.js";import{M as he}from"./MainLayout-IssbuzrT.js";import{r as te}from"./BoltIcon-DjHUJwe3.js";import{P as ve}from"./PostModal-CtTH1YAt.js";import"./PaperAirplaneIcon-CIWf5ciy.js";const be={class:"banner-section relative h-32 bg-gradient-to-br from-accent to-primary"},pe=["src","alt"],xe={class:"icon-overlay absolute bottom-0 left-4 transform translate-y-1/2"},we={key:0,class:"icon-wrapper w-16 h-16 rounded-full bg-white dark:bg-gray-800 border-4 border-white dark:border-gray-800 shadow-lg overflow-hidden flex items-center justify-center"},_e=["src","alt"],ke={key:1,class:"icon-wrapper w-16 h-16 rounded-full bg-gradient-to-br from-accent to-primary border-4 border-white dark:border-gray-800 shadow-lg flex items-center justify-center"},Ce={class:"text-white text-xl font-bold"},Ie={class:"top-right-icons absolute top-3 right-3 flex gap-2"},$e={class:"icon-circle w-6 h-6 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center"},je={class:"icon-circle w-6 h-6 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center"},Pe={class:"content-section p-5 pt-8"},Me={class:"text-lg font-bold text-gray-900 dark:text-white mb-2 line-clamp-1"},Ee={class:"text-sm text-gray-600 dark:text-gray-400 mb-4 line-clamp-2 min-h-[2.5rem]"},qe={class:"metrics flex items-center gap-4 mb-4"},Le={class:"metric flex items-center gap-1.5"},Se={class:"text-sm text-gray-700 dark:text-gray-300 font-medium"},Ue={class:"metric flex items-center gap-1.5"},Fe={class:"text-sm text-gray-700 dark:text-gray-300 font-medium"},Ne={key:0,class:"tags flex flex-wrap gap-2"},Be=V({__name:"CommunityCard",props:{community:{}},setup(o){const x=o,s=ie(),C=h(!1),w=h(!1),_=d=>d?d.replace(/,\s*$/,"").trim():"",q=()=>{w.value=!0},m=()=>{C.value=!0},I=d=>{if(!d)return"?";const f=d.trim().split(/\s+/);return f.length>=2?(f[0][0]+f[1][0]).toUpperCase():d.substring(0,2).toUpperCase()},$=d=>{if(d==null||d==="")return"0";const f=typeof d=="string"?parseInt(d,10):d;return isNaN(f)||f===null||f===void 0?"0":f>=1e6?(f/1e6).toFixed(1)+"M":f>=1e3?(f/1e3).toFixed(1)+"K":f.toString()},j=()=>{s.push(`/community/${x.community.unique_code}`)};return(d,f)=>(c(),y("div",{class:"community-card bg-white dark:bg-gray-800 rounded-xl overflow-hidden shadow-md hover:shadow-lg transition-all cursor-pointer border border-gray-200 dark:border-gray-700",onClick:j},[e("div",be,[o.community.banner_img_url?(c(),y("img",{key:0,src:_(o.community.banner_img_url),alt:o.community.title,class:"w-full h-full object-cover",onError:q},null,40,pe)):S("",!0),e("div",xe,[o.community.icon_img_url?(c(),y("div",we,[e("img",{src:_(o.community.icon_img_url),alt:o.community.title,class:"w-full h-full object-cover",onError:m},null,40,_e)])):(c(),y("div",ke,[e("span",Ce,p(I(o.community.title)),1)]))]),e("div",Ie,[e("div",$e,[k(E(X),{class:"w-3.5 h-3.5 text-white"})]),e("div",je,[k(E(Y),{class:"w-3.5 h-3.5 text-white"})])])]),e("div",Pe,[e("h3",Me,p(o.community.title),1),e("p",Ee,p(o.community.description||"No description available"),1),e("div",qe,[e("div",Le,[k(E(Z),{class:"w-4 h-4 text-gray-500 dark:text-gray-400"}),e("span",Se,p($(o.community.members_snapshot)),1)]),e("div",Ue,[k(E(te),{class:"w-4 h-4 text-gray-500 dark:text-gray-400"}),e("span",Fe,p($(o.community.activity_snapshot||0)),1)])]),o.community.tags&&o.community.tags.length>0?(c(),y("div",Ne,[(c(!0),y(G,null,O(o.community.tags.slice(0,3),(L,U)=>(c(),y("span",{key:U,class:"tag px-2.5 py-1 rounded-full text-xs font-medium border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-gray-700 dark:text-gray-300"},p(L),1))),128))])):S("",!0)])]))}}),Ae=D(Be,[["__scopeId","data-v-88c7ce87"]]),Re={key:0,class:"community-header bg-white dark:bg-gray-800 rounded-2xl overflow-hidden shadow-lg border border-gray-200 dark:border-gray-700 mb-6"},Je={class:"banner-section relative h-48 md:h-64 bg-gradient-to-br from-accent to-primary"},Ve=["src","alt"],De={class:"icon-overlay absolute bottom-0 left-6 md:left-8 transform translate-y-1/2"},Ke={key:0,class:"icon-wrapper w-20 h-20 md:w-24 md:h-24 rounded-full bg-white dark:bg-gray-800 border-4 border-white dark:border-gray-800 shadow-xl overflow-hidden flex items-center justify-center"},Te=["src","alt"],We={key:1,class:"icon-wrapper w-20 h-20 md:w-24 md:h-24 rounded-full bg-gradient-to-br from-accent to-primary border-4 border-white dark:border-gray-800 shadow-xl flex items-center justify-center"},ze={class:"text-white text-2xl md:text-3xl font-bold"},He={class:"top-right-icons absolute top-4 right-4 md:top-6 md:right-6 flex gap-2"},Qe={class:"icon-circle w-7 h-7 md:w-8 md:h-8 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center"},Ge={class:"icon-circle w-7 h-7 md:w-8 md:h-8 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center"},Oe={class:"content-section p-6 md:p-8 pt-12 md:pt-16"},Xe={class:"text-2xl md:text-3xl font-bold text-gray-900 dark:text-white mb-3"},Ye={class:"text-base text-gray-600 dark:text-gray-400 mb-6"},Ze={class:"metrics flex items-center gap-6 mb-6"},et={class:"metric flex items-center gap-2"},tt={class:"text-lg font-semibold text-gray-900 dark:text-white"},ot={class:"metric flex items-center gap-2"},rt={class:"text-lg font-semibold text-gray-900 dark:text-white"},st={key:0,class:"join-section"},nt=["disabled"],at={key:0,class:"flex items-center gap-2"},it={key:1},lt={key:1,class:"community-header-loading bg-white dark:bg-gray-800 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700 mb-6 p-12"},ct=V({__name:"CommunityHeader",props:{community:{},loading:{type:Boolean},isMember:{type:Boolean},membershipLoading:{type:Boolean}},emits:["joined","show-sign-in"],setup(o,{emit:x}){const s=o,C=x,w=ee(),_=h(!1),q=h(!1),m=h(!1),I=J(()=>{if(!s.community)return!1;const n=s.community.member_subscription_fee;return n==null||n===""||n===0||n==="0"}),$=async()=>
1{if(!(!s.community||m.value)){if(!w.isAuthenticated){C("show-sign-in");return}m.value=!0;try{const n={requestorUserId:w.userId};s.community.id&&(n.communityId=s.community.id),s.community.unique_code&&(n.uniqueCode=s.community.unique_code),s.community.community_code&&(n.communityCode=s.community.community_code);const t=await N.joinCommunity(n);t.success?C("joined"):(console.error("Failed to join community:",t.error),alert(t.error||"Failed to join community. Please try again."))}catch(n){console.error("Error joining community:",n),alert("An error occurred while joining the community. Please try again.")}finally{m.value=!1}}},j=n=>n?n.replace(/,\s*$/,"").trim():"",d=()=>{q.value=!0},f=()=>{_.value=!0},L=n=>{if(!n)return"?";const t=n.trim().split(/\s+/);return t.length>=2?(t[0][0]+t[1][0]).toUpperCase():n.substring(0,2).toUpperCase()},U=n=>{const t=typeof n=="string"?parseInt(n,10):n;return isNaN(t)?"0":t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toString()};return(n,t)=>o.community?(c(),y("div",Re,[e("div",Je,[o.community.banner_img_url?(c(),y("img",{key:0,src:j(o.community.banner_img_url),alt:o.community.title,class:"w-full h-full object-cover",onError:d},null,40,Ve)):S("",!0),e("div",De,[o.community.icon_img_url?(c(),y("div",Ke,[e("img",{src:j(o.community.icon_img_url),alt:o.community.title,class:"w-full h-full object-cover",onError:f},null,40,Te)])):(c(),y("div",We,[e("span",ze,p(L(o.community.title)),1)]))]),e("div",He,[e("div",Qe,[k(E(X),{class:"w-4 h-4 md:w-5 md:h-5 text-white"})]),e("div",Ge,[k(E(Y),{class:"w-4 h-4 md:w-5 md:h-5 text-white"})])])]),e("div",Oe,[e("h1",Xe,p(o.community.title),1),e("p",Ye,p(o.community.description||"No description available"),1),e("div",Ze,[e("div",et,[k(E(Z),{class:"w-5 h-5 text-gray-500 dark:text-gray-400"}),e("div",null,[t[0]||(t[0]=e("div",{class:"text-sm text-gray-500 dark:text-gray-400"},"Members",-1)),e("div",tt,p(U(o.community.members_snapshot)),1)])]),e("div",ot,[k(E(te),{class:"w-5 h-5 text-gray-500 dark:text-gray-400"}),e("div",null,[t[1]||(t[1]=e("div",{class:"text-sm text-gray-500 dark:text-gray-400"},"Activity",-1)),e("div",rt,p(U(o.community.activity_snapshot||0)),1)])])]),!o.membershipLoading&&!o.isMember?(c(),y("div",st,[e("button",{onClick:$,disabled:m.value,class:le(["join-btn w-full md:w-auto px-6 py-3 rounded-lg font-semibold text-white transition-all disabled:opacity-50 disabled:cursor-not-allowed",I.value?"bg-green-600 hover:bg-green-700":"bg-accent hover:bg-opacity-90"])},[m.value?(c(),y("span",at,[...t[2]||(t[2]=[e("span",{class:"spinner-border inline-block w-4 h-4 border-2 border-primary border-r-transparent rounded-full animate-spin"},null,-1),ce(" Joining... ",-1)])])):(c(),y("span",it,p(I.value?"Join Free":"Join"),1))],10,nt)])):S("",!0)])])):o.loading?(c(),y("div",lt,[...t[3]||(t[3]=[e("div",{class:"text-center"},[e("div",{class:"spinner-border inline-block w-12 h-12 border-4 border-primary border-r-transparent rounded-full animate-spin"})],-1)])])):S("",!0)}}),dt=D(ct,[["__scopeId","data-v-5717124c"]]),ut={key:0,class:"communities-container max-w-7xl mx-auto px-4 py-6"},mt={class:"communities-grid grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6"},yt={key:0,class:"text-center py-12"},ft={key:1,class:"text-center py-6"},gt={key:2,class:"text-center py-12"},ht={key:1,class:"community-posts-container max-w-7xl mx-auto px-4 py-6"},vt=V({__name:"CommunityView",setup(o){const x=de(),s=ee(),C=h(null),w=h([]),_=h(!1),q=h(1),m=h(null),I=h(!1),$=h(!1),j=h(!1),d=h([]),f=h(!1),L=h(1),U=h(!1),n=h(null);J(()=>{var l;return((l=C.value)==null?void 0:l.isMobile)??window.innerWidth<768});const t=J(()=>x.params.communityCode);async function K(){var l,i,a;if(!_.value){_.value=!0;try{const r={page:q.value,recordsPerPage:20};s.userId&&(r.requestorUserId=s.userId);const u=await N.getCommunities(r);if(u.success&&u.data){const g=(i=(l=u.data)==null?void 0:l.results)==null?void 0:i[0],v=(g==null?void 0:g.payload)||((a=u.data)==null?void 0:a.payload)||[];q.value===1?w.value=v:w.value.push(...v),v.length>0&&q.value++}}catch(r){console.error("Error loading communities:",r)}finally{_.value=!1}}}async function B(){var l,i,a;
1if(!(j.value||!s.userId||!m.value)){j.value=!0,$.value=!1;try{const r={requestorUserId:s.userId},u=await N.getCommunityMembership(r);if(u.success&&u.data){const g=(i=(l=u.data)==null?void 0:l.results)==null?void 0:i[0],v=(g==null?void 0:g.payload)||((a=u.data)==null?void 0:a.payload)||[],P=m.value.id||m.value.community_id,F=v.find(M=>{var z;const W=M.community_id||M.id||((z=M.community)==null?void 0:z.id);return W===P||W===String(P)||M.community_code===m.value.unique_code||M.community_code===m.value.community_code||M.unique_code===m.value.unique_code});$.value=!!F}}catch(r){console.error("Error loading community membership:",r),$.value=!1}finally{j.value=!1}}}async function oe(){var l,i,a;if(!(I.value||!t.value)){I.value=!0;try{const r={page:1,recordsPerPage:100,community_code:t.value};s.userId&&(r.requestorUserId=s.userId);const u=await N.getCommunities(r);if(u.success&&u.data){const g=(i=(l=u.data)==null?void 0:l.results)==null?void 0:i[0],v=(g==null?void 0:g.payload)||((a=u.data)==null?void 0:a.payload)||[],P=v.find(F=>F.unique_code===t.value||F.community_code===t.value);if(P)m.value=P,s.userId&&await B();else if(v.length>0)if(v.length===1)m.value=v[0],s.userId&&await B();else{const F=v.find(M=>M.unique_code===t.value||M.community_code===t.value);F&&(m.value=F,s.userId&&await B())}}}catch(r){console.error("Error loading community details:",r)}finally{I.value=!1}}}async function T(){var l,i,a,r;if(!(f.value||!t.value)){f.value=!0;try{const u={page:L.value,recordsPerPage:10,postType:"community_feed",feedCommunityCode:t.value};s.userId&&(u.requestorUserId=s.userId);const g=await N.getFeedPosts(u);if(g.success&&g.data){const v=(i=(l=g.data)==null?void 0:l.results)==null?void 0:i[0],P=(v==null?void 0:v.payload)||((a=g.data)==null?void 0:a.payload)||((r=g.data)==null?void 0:r.data)||[];L.value===1?d.value=P:d.value.push(...P),P.length>0&&L.value++}}catch(u){console.error("Error loading community posts:",u)}finally{f.value=!1}}}function re(){K()}function se(){T()}async function ne(){s.userId&&m.value&&await B()}function ae(){C.value&&(C.value.showSignInModal=!0)}function A(){t.value&&(m.value=null,L.value=1,d.value=[],Q(()=>{oe(),T()}))}function R(){m.value=null,d.value=[],q.value=1,w.value=[],Q(()=>{K()})}ue((l,i)=>{const a=l.params.communityCode,r=i.params.communityCode;a&&a!==r?A():r&&!a&&R()});const b=h(void 0);return me(()=>[x.path,x.params.communityCode],(l,i)=>{const[a,r]=l||[x.path,x.params.communityCode],[u,g]=i||[void 0,void 0];if(a!=null&&a.startsWith("/community")){if(b.value===void 0&&(u===void 0||u===a)){r?(b.value=r,A()):(b.value=void 0,R());return}r===g&&r===b.value||(r?r!==b.value&&(b.value=r,A()):(g||b.value!==void 0)&&(b.value=void 0,R()))}},{immediate:!0}),ye(()=>{s.initializeAuth();const l=x.params.communityCode;x.path.startsWith("/community")&&(l&&l!==b.value?(b.value=l,A()):!l&&b.value===void 0&&(b.value=void 0,R()))}),(l,i)=>(c(),H(he,{"show-category-tabs":!1,"show-floating-actions":!0,ref_key:"layoutRef",ref:C,"force-login":!E(s).isAuthenticated},{default:fe(()=>[t.value?(c(),y("div",ht,[k(dt,{community:m.value,loading:I.value,"is-member":$.value,"membership-loading":j.value,onJoined:ne,onShowSignIn:ae},null,8,["community","loading","is-member","membership-loading"]),k(ge,{posts:d.value,loading:f.value,onLoadMore:se},null,8,["posts","loading"]),k(ve,{open:U.value,"onUpdate:open":i[0]||(i[0]=a=>U.value=a),post:n.value},null,8,["open","post"])])):(c(),y("div",ut,[i[3]||(i[3]=e("div",{class:"mb-6"},[e("h1",{class:"text-3xl font-bold text-accent dark:text-primary mb-2"},"Communities"),e("p",{class:"text-gray-600 dark:text-gray-400"},"Discover and join communities that matter to you")],-1)),e("div",mt,[(c(!0),y(G,null,O(w.value,a=>(c(),H(Ae,{key:a.id||a.unique_code,community:a},null,8,["community"]))),128))]),_.value?(c(),y("div",yt,[...i[1]||(i[1]=[e("div",{class:"spinner-border inline-block w-12 h-12 border-4 border-primary border-r-transparent rounded-full animate-spin"},null,-1)])])):S("",!0),!_.value&&w.value.length>0?(c(),y("div",ft,[e("button",{class:"btn-primary px-6 py-2 rounded-full",onClick:re}," Load More ")])):S("",!0),!_.value&&w.value.length===0?(c(),y("div",gt,[...i[2]||(i[2]=[e("p",{class:"text-gray-600 dark:text-gray-400 text-lg"},"No communities found",-1)])])):S("",!0)]))]),_:1},8,["force-login"]))}}),Ct=D(vt,[["__scopeId","data-v-7308befd"]]);export{Ct 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.