1import{r as n,j as e}from"./vendor-react-DRS4EotE.js";import{z as ne,i as f,B,T as N,a as Ce,M as Ie,m as I,W as ce,c0 as ke,b$ as Te,U as le,dB as Me,v as Y,I as L,en as de,b as Fe,eo as De,g as Le,ep as H}from"./index-DTpPjP10.js";import{u as Be}from"./useDebounce-DoTpCR0r.js";import{S as C}from"./index-DmXaklaZ.js";import{I as Ve}from"./index-fV67oPGi.js";import{S as Ee}from"./index-CBq8FmUT.js";import{g as Oe}from"./country-C9icu9cG.js";import{u as oe}from"./useMutation-D8gvRn_S.js";import{L as ze}from"./link-La1jzCl6.js";import{c as Ae}from"./vendor-recharts-BsPIiKg0.js";import{b as $e,i as Re,V as qe}from"./index-zqiqxgx5.js";import{B as $}from"./index-BCZxtM1D.js";import{u as Qe}from"./useDialogQueue-BMbFwGMF.js";import{u as Ge,z as Ke}from"./validator-BZhWqyxX.js";import{M as We}from"./MultiComboboxEdit-BPjuoS9r.js";import{S as He}from"./SDGIconList-CI1nl2ml.js";import{T as re}from"./index-dSULqxOI.js";import{d as Ue}from"./tags-BK7StjnZ.js";import{P as Ye}from"./ProjectApprovalActions-DtgmprVJ.js";import{F as Je}from"./index-DA2U9_Z3.js";import{S as Xe}from"./index-IOZz3gND.js";import{a as Ze}from"./utils-D89dfb7w.js";import{u as es}from"./useInfiniteScroll-BltTe6U0.js";import{b as ss}from"./utils-CnSqmTc8.js";import{D as ts}from"./index-BGAoyMcl.js";import{M as as,L as ns,a as ls}from"./index-6zQfHmMO.js";import{B as os}from"./ButtonLink-CBRrUHiW.js";import"./vendor-doc-viewer-BGof5Md4.js";import"./input-bphx-5wg.js";import"./label-CQNGzSR-.js";import"./index-H0kb4noh.js";import"./popover-Dq8EkW-o.js";import"./use-resolve-button-type-B-_pf3C9.js";import"./floating-ui.react-dom-B37uq3Ad.js";import"./utils-lQjZR7kg.js";import"./file-Cd-UCsqC.js";import"./file-BJurHq7E.js";import"./index-DLoMEt3T.js";import"./use-default-value-B-M1WjYw.js";import"./combobox-DXVIRfcW.js";import"./listbox-7lFOR7Vy.js";import"./use-text-value-BcDfHGma.js";import"./use-tree-walker-B1B3I0uB.js";import"./index-C9PBdAgp.js";import"./index-Cc82Rz5V.js";import"./index-B9Vy9EWC.js";import"./radio-group-cYcrKdyz.js";import"./common-DQN8W4b_.js";import"./array-Qdzv_pEH.js";import"./project-pLR52PZF.js";import"./index-DtYxoxOP.js";import"./index-BXwa60pF.js";import"./useMediaQuery--HNQdeGX.js";const rs=({tags:s,availableTags:l,mutation:o,onClose:r})=>{const[p,d]=n.useState(Array.from(new Set([...s,...l])).map(a=>({id:a,label:a})).sort((a,i)=>a.label.localeCompare(i.label))),j={tags:{onBlur:ne.array(ne.string())}},g=Ge({defaultValues:{tags:s||[]},onSubmit:a=>{o.mutate(a.value.tags),r()},validatorAdapter:Ke()}),x=()=>{g.reset(),r()};return e.jsxs("form",{onSubmit:a=>{a.preventDefault(),a.stopPropagation(),g.handleSubmit()},children:[e.jsx(g.Field,{name:"tags",validators:j.tags,children:a=>e.jsx(We,{options:p,placeholder:f._({id:"project_overview_tags_placeholder"}),value:a.state.value.map(i=>({id:i,label:i})),onSelect:i=>{a.handleChange(i.map(m=>m.id))},onAddOption:i=>{const m={id:i,label:i};a.handleChange([...a.state.value,m.id]),d([...p,m].sort((w,h)=>w.label.localeCompare(h.label)))},onRemoveOption:i=>a.handleChange(a.state.value.filter(m=>m!==i.id))})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(B,{variant:"secondary",small:!0,onClick:x,children:e.jsx(N,{id:"cancel"})}),e.jsx(B,{type:"submit",small:!0,children:e.jsx(N,{id:"save"})})]})]})},U=({project:s,isPending:l=!1,awaitingApproval:o=!1,onStatusChange:r})=>{var y;const p=Ce(),d=Ie(),{enqueueDialog:j,closeCurrentDialog:g}=Qe(),{data:x=[]}=I(Ue(d)),{data:a}=I(ce(d)),i=(a==null?void 0:a.canEditProjectTags)??!1,[m,w]=n.useState(null),h=m??s.isFollowing;n.useEffect(()=>{w(null)},[s.isFollowing]);const k=oe({mutationFn:()=>h?ke(s.id||0,d||0):Te(s.id||0,d||0),onSuccess:()=>{w(!h),p.invalidateQueries({queryKey:le.all})}}),_=oe({mutationFn:c=>Me({projectId:s.id||0,projectTags:c}),onSuccess:()=>{p.invalidateQueries({queryKey:le.all})}}),b=((y=s.projectSustainableDevelopmentGoals)==null?void 0:y.map(c=>c.sustainableDevelopmentGoalId||0))||[];return e.jsxs("div",{className:"flex flex-col overflow-hidden rounded-lg border border-pearl-lighter bg-white shadow-primary",children:[e.jsxs(ze,{to:"/community/$communityId/project/$projectId",params:{communityId:String(d||0),projectId:String(s.id||0)},className:"relative w-full",children:[e.jsx("div",{className:Ae("relative mt-6 w-full overflow-hidden bg-pearl-lighter",$e),children:s.mainImageOrVideo&&Re(s.mainImageOrVideo)?e.jsx(qe,{url:s.mainImageOrVideo,title:s.name||"",className:"h-full w-full"}):e.jsx(Y,{src:s.mainImageOrVideo||null,alt:s.name||"",className:"h-full w-full object-cover",lazy:!0})}
1),e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 h-20 bg-[linear-gradient(to_bottom,white_0%,white_30%,transparent_100%)]"}),e.jsxs("div",{className:"absolute left-0 right-0 top-0 flex items-center gap-3 px-4 py-3",children:[e.jsx(Y,{src:s.logoImage,alt:s.name||"",className:"h-8 w-8 rounded-lg object-cover"}),e.jsx("span",{className:"flex-1 truncate text-paragraph-medium font-semibold text-black",children:s.name}),o&&e.jsx($,{color:"yellow",className:"shrink-0",children:e.jsx(N,{id:"startup_pending_approval_badge"})}),!l&&!o&&!!d&&(m!==null||s.isFollowing||s.canFollow)&&e.jsx(B,{variant:"secondary",small:!0,onClick:c=>{c.preventDefault(),c.stopPropagation(),k.mutate()},disabled:k.isPending,children:h?e.jsx(N,{id:"unfollow"}):e.jsx(N,{id:"follow"})})]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-3 p-4",children:[(s.city||s.countryName)&&e.jsxs("div",{className:"flex items-center gap-1 border-b border-pearl-lighter pb-2",children:[e.jsx(L,{icon:"pin_drop",className:"text-blue",size:"default"}),e.jsxs("span",{className:"text-paragraph-medium text-pearl-dark",children:[s.city&&e.jsx("span",{children:s.countryName?`${s.city}, `:`${s.city}`}),s.countryName&&e.jsx("span",{children:s.countryName})]})]}),s.description&&e.jsx("p",{className:"text-paragraph-medium text-pearl-dark",children:s.description}),e.jsxs("div",{className:"mt-auto flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.projectTags&&s.projectTags.length===1&&e.jsx(re,{content:s.projectTags[0],children:e.jsxs($,{color:"blue",className:"flex shrink-0 items-center gap-1 border-0",children:[e.jsx(L,{icon:"description",className:"text-blue",size:"small"}),e.jsx("span",{className:"max-w-[120px] truncate",children:s.projectTags[0]})]})}),s.projectTags&&s.projectTags.length>1&&e.jsx(re,{content:e.jsx("div",{className:"flex flex-col gap-1",children:s.projectTags.map(c=>e.jsx("span",{children:c},c))}),children:e.jsxs($,{color:"blue",className:"flex shrink-0 items-center gap-1 border-0",children:[e.jsx(L,{icon:"description",className:"text-blue",size:"small"}),s.projectTags.length]})}),i&&e.jsx($,{color:"blue",className:"flex shrink-0 cursor-pointer items-center gap-1 border-0",onClick:c=>{c.preventDefault(),c.stopPropagation(),j({title:f._({id:"project_overview_tags"}),children:e.jsx(rs,{tags:s.projectTags||[],availableTags:x,onClose:g,mutation:_}),onClose:g})},children:e.jsx(L,{icon:s.projectTags&&s.projectTags.length>0?"edit":"add",className:"text-blue",size:"default"})})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-2",children:b.length>0&&e.jsx(He,{sdgIds:b,size:"small"})})]}),l&&e.jsx("div",{className:"flex gap-2 [&>*]:flex-1",children:e.jsx(Ye,{project:s,onStatusChange:r})})]})]})},is=({filters:s,values:l,onChange:o,route:r,orderBy:p,onOrderByChange:d,isDevelopmentStageVisible:j,isSDGsVisible:g})=>{var h,k,_,b,y,c;const x=n.useMemo(()=>Ze(s,j,g),[s,j,g]),a=n.useMemo(()=>[{id:0,label:f._({id:"sort_alphabetically"})},{id:1,label:f._({id:"sort_recently_created"})},{id:2,label:f._({id:"sort_number_of_views"})},{id:3,label:f._({id:"sort_number_of_comments"})},{id:4,label:f._({id:"sort_number_of_followers"})},{id:5,label:f._({id:"sort_recently_modified"})}],[]),i=s&&(((h=s.countries)==null?void 0:h.length)||((k=s.industries)==null?void 0:k.length)||((_=s.sustainableDevelopmentGoals)==null?void 0:_.length)||((b=s.tags)==null?void 0:b.length)||((y=s.programs)==null?void 0:y.length)||((c=s.developmentStages)==null?void 0:c.length)),m=x.filters,w=((m==null?void 0:m.length)??0)>0;return e.jsxs("div",{className:"flex flex-col gap-4",children:[(i||w)&&e.jsx(Je,{values:l,optionValues:x,onChange:o,route:r,defaultValues:{},display:"grid",showResetButton:!0,showLabels:!1}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Xe,{insideLabel:f._({id:"network_sorted_by"}),options:a,value:a.find(P=>P.id===p)||a[0]||null,onSelect:P=>{d(P.id)},optionsDropdownWidth:"w-auto"})})]})},cs=({project:s,communityId:l})=>{const o=s.name||f._({id:"project_unknown"}
1),r=[s.city,s.countryName].filter(Boolean).join(", ");return e.jsxs("div",{className:"flex w-60 flex-col gap-2 rounded-xl border border-pearl-lighter bg-white p-3 shadow-md",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Y,{src:s.logoImage,alt:o,className:"size-12 shrink-0 rounded-lg bg-white object-contain"}),e.jsxs("div",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate text-paragraph-medium font-semibold text-black",children:o}),s.developmentStage?e.jsx("span",{className:"truncate text-paragraph-small text-pearl-dark",children:s.developmentStage}):null,r?e.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1 text-paragraph-small text-pearl-dark",children:[e.jsx(L,{icon:"pin_drop",className:"shrink-0 text-blue",size:"xsmall"}),e.jsx("span",{className:"truncate",children:r})]}):null]})]}),s.id!=null?e.jsx(os,{variant:"ternary",extraSmall:!0,className:"w-full justify-center",to:"/community/$communityId/project/$projectId",params:{communityId:String(l),projectId:String(s.id)},children:e.jsx(N,{id:"map_open_project"})}):null]})},ds=s=>{const{data:l}=I({...de({...s,skip:0}),placeholderData:(g,x)=>{const[,,a]=(x==null?void 0:x.queryKey)??[];return(a==null?void 0:a.communityId)===s.communityId?g:void 0}}),o=n.useMemo(()=>(l==null?void 0:l.pendingProjects)??[],[l==null?void 0:l.pendingProjects]),[r,p]=n.useState(o);n.useEffect(()=>{p(o)},[o]);const d=n.useMemo(()=>(l==null?void 0:l.myPendingProjects)??[],[l==null?void 0:l.myPendingProjects]);return{pendingProjects:r,removePendingProject:g=>{p(x=>x.filter(a=>a.id!==g))},myPendingProjects:d,canCreateProjects:(l==null?void 0:l.canCreateProjects)??!1}},ie=20,ms=({communityId:s,openPendingDrawer:l=!1,onPendingDrawerClose:o})=>{const[r,p]=n.useState(0),[d,j]=n.useState(!1),[g,x]=n.useState(!1),[a,i]=n.useState(!1),[m,w]=n.useState(""),[h,k]=n.useState(1),[_,b]=n.useState([]),[y,c]=n.useState(null),[P,me]=n.useState({}),[F,ue]=n.useState(!1),[pe,ge]=n.useState(null),xe=Fe(),R=Be(m,500),E=n.useMemo(()=>{const{filters:t,...u}=P,z=ss(u),D=t==null?void 0:t.map(V=>({question:V.question,answers:V.answers}));return{communityId:s,concept:R||void 0,filters:D&&D.length>0?D:void 0,orderBy:h,skip:r,take:ie,...z}},[P,R,h,r,s]),{data:T,isPending:q}=I(de(E)),{data:v}=I(ce(s)),{pendingProjects:M,removePendingProject:he,myPendingProjects:O,canCreateProjects:fe}=ds(E);n.useEffect(()=>{var z,D;if(!T){r===0&&(b([]),c(null));return}const t=((z=T.projects)==null?void 0:z.list)||[],u=((D=T.projects)==null?void 0:D.count)||0;r===0?(b(t),c(u)):b(V=>{const Pe=new Set(V.map(A=>A.id)),Se=t.filter(A=>A.id&&!Pe.has(A.id));return[...V,...Se]})},[T,r]),n.useEffect(()=>{p(0)},[P,R,h]);const J=y!==null&&_.length<y,X=q&&r>0,Q=q&&r===0,Z=n.useMemo(()=>{const t=new Set(O.map(u=>u.id));return _.filter(u=>!t.has(u.id))},[_,O]),ee=O.length>0||Z.length>0,je=g||l&&!a&&M.length>0,be=n.useMemo(()=>{const t={...E};return delete t.skip,delete t.take,t},[E]),{data:se=[],isFetching:ye}=I({...De(be),enabled:F}),{data:te=[]}=I({...Oe(),enabled:F}),{data:S}=I({...Le(),enabled:F}),ve=typeof(S==null?void 0:S.latitude)=="number"&&typeof(S==null?void 0:S.longitude)=="number"?[S.latitude,S.longitude]:void 0,ae=n.useMemo(()=>{const t=new Map;for(const u of te)u.id!=null&&u.name&&t.set(u.id,u.name);return t},[te]),Ne=n.useMemo(()=>se.filter(t=>typeof t.latitude=="number"&&typeof t.longitude=="number").map(t=>({id:t.id??`${t.latitude},${t.longitude}`,lat:t.latitude,lng:t.longitude,iconUrl:t.logoImage,iconLabel:t.name??"",iconShape:"rounded-square",popup:e.jsx(cs,{project:{id:t.id,name:t.name,logoImage:t.logoImage,city:t.city,countryName:t.countryId!=null?ae.get(t.countryId)??null:null,developmentStage:t.developmentStage},communityId:s})})),[se,ae,s]),G=F?"grid grid-cols-1 gap-4 xl:grid-cols-2":"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",we=es({isLoading:X,hasMore:J,onLoadMore:()=>{J&&!q&&p(t=>t+ie)},root:pe}),K=n.useCallback(()=>{x(!1),i(!0),o==null||o()},[o]),W=n.useRef(!1);n.useEffect(()=>{M.length>0||!W.current||(W.current=!1,K())},[M,K]);const _e=t=>{t&&(W.current=!0,he(t))};return e.jsxs("div",{className:"flex flex-col gap-6 lg:h-full lg:min-h-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(B,{variant:"secondary",small:!0,onClick:()=>j(!d),children:e.jsx(L,{icon:"filter_list",size:"large"})}),e.jsx(Ee,{onChange:t=>{w(t)},value:m,placeholder:f._({id:"search_projects_placeholder",values:{0:y??0}})}),e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[((v
1==null?void 0:v.isMapVisible)??!0)&&e.jsx(as,{mapEnabled:F,onToggle:()=>ue(t=>!t)}),M.length>0&&e.jsx(B,{variant:"secondary",small:!0,icon:"hourglass_empty",className:"min-h-[38px]",onClick:()=>x(!0),children:e.jsx(N,{values:{0:M.length},components:{0:e.jsx("span",{className:"sr-only md:not-sr-only"})},id:"projects_pending_count"})}),fe&&e.jsx(B,{variant:"primary",small:!0,icon:"add",className:"min-h-[38px]",onClick:()=>{xe({to:"/community/$communityId/project/create",params:{communityId:String(s)}})},children:e.jsx("span",{className:"sr-only md:not-sr-only",children:e.jsx(N,{id:"create_new_project"})})})]})]}),d&&e.jsx("div",{className:"mb-4",children:e.jsx(is,{filters:(T==null?void 0:T.projectFilters)||null,values:P,onChange:me,route:"/_auth/_community/community/$communityId/projects/",orderBy:h,onOrderByChange:k,isDevelopmentStageVisible:(v==null?void 0:v.isDevelopmentStageVisible)??!1,isSDGsVisible:(v==null?void 0:v.isSDGsVisible)??!1})}),e.jsx(ns,{mapEnabled:F,onScrollContainerRef:ge,list:e.jsxs(e.Fragment,{children:[Q&&e.jsx("div",{className:G,children:Array.from({length:8}).map((t,u)=>e.jsxs("div",{className:"flex flex-col overflow-hidden rounded-lg border border-pearl-lighter bg-white",children:[e.jsx(C,{className:"aspect-5/2 w-full"}),e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx(C,{className:"h-4 w-3/4 rounded"}
1),e.jsx(C,{className:"h-4 w-1/2 rounded"}),e.jsx(C,{className:"h-10 w-full rounded"})]})]},u))}),!Q&&ee&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:G,children:[O.map(t=>e.jsx(U,{project:t,awaitingApproval:!0},t.id)),Z.map(t=>e.jsx(U,{project:t},t.id))]}),X&&e.jsx("div",{className:G,children:Array.from({length:4}).map((t,u)=>e.jsxs("div",{className:"flex flex-col overflow-hidden rounded-lg border border-pearl-lighter bg-white",children:[e.jsx(C,{className:"aspect-5/2 w-full"}),e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx(C,{className:"h-4 w-3/4 rounded"}),e.jsx(C,{className:"h-4 w-1/2 rounded"}),e.jsx(C,{className:"h-10 w-full rounded"})]})]},u))}),e.jsx("div",{ref:we,className:"h-4"})]}),!Q&&!ee&&e.jsx(Ve,{type:"default",className:"mb-4",text:f._({id:"no_projects_found"})})]}),map:e.jsx(ls,{markers:Ne,isLoading:ye,defaultCenter:ve})}),e.jsx(ts,{open:je,position:"right",closeDrawer:K,title:f._({id:"projects_pending"}),className:"w-full pb-20 md:w-[600px]",children:e.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:M.length>0?e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:M.map(t=>e.jsx(U,{project:t,isPending:!0,onStatusChange:_e},t.id))}):e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("span",{className:"text-paragraph-medium text-pearl-dark",children:e.jsx(N,{id:"projects_no_pending"})})})})})})]})},mt=function(){const{communityId:l}=H.useParams(),{pending:o}=H.useSearch(),r=H.useNavigate(),p=parseInt(l,10),d=()=>{o&&r({search:j=>({...j,pending:void 0}),replace:!0})};return e.jsx(ms,{communityId:p,openPendingDrawer:o,onPendingDrawerClose:d})};export{mt as component}; 2//# sourceMappingURL=index-BrfaMLId.js.map
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.