import{r as e,E as s,F as a,k as n,as as t,at as r,ap as o,ao as i,X as l,K as c,T as m,w as d,p,D as u,b0 as x,ah as h,M as g,z as j}from"./mui-D5z84GQJ.js";import{s as f}from"./model-C3YGvFr4.js";import{d as C,a as b}from"./CheckBoxOutlineBlank-CcZ36mCm.js";import{c as y,u as w,q as k,e as v,b as L,a9 as I,s as F,i as N,H as S,I as O,a4 as T,a6 as B,bm as P,a7 as z,L as A,bn as E,b6 as q}from"./index-4pqGAE6E.js";import{C as D}from"./ContentContainer-D1IbXDVF.js";const $=n.jsx(C,{fontSize:"small"}),H=n.jsx(b,{fontSize:"small"});function V({causeAreas:s,removeCause:a,clearCauses:t}){const r=v(),o={deleteIcon:n.jsx(q,{}),size:"small",color:"info"};return n.jsxs(n.Fragment,{children:[s.map((s=>e.createElement(p,{...o,label:s,key:s,onDelete:()=>{a(s)}}))),s.length>0&&n.jsx(j,{onClick:t,size:"small",className:r.filterClearButton,children:"Clear all"})]})}function J(){const x=y(),{trackVisitInCIO:h}=w(),g=k.parse(location.search,{ignoreQueryPrefix:!0}),[j,f]=e.useState(void 0),[C,b]=e.useState(null),E=v(),q=L(),$=I(),H=s(),[V,J]=e.useState({}),R=Object.entries(V),[U,X]=e.useState(g),G=a(H.breakpoints.down("lg")),W=a(H.breakpoints.down("sm")),Y=a(H.breakpoints.between("sm","lg"));e.useEffect((()=>{h("List nonprofits")}),[]),e.useEffect((()=>{const e=new AbortController;return void 0===U.region?f(void 0):(x.listNpos({causes:U.causes,namelike:U.namelike,region:U.region},e).then((e=>{f(e.data.nonProfitOrgs)})),F(U),()=>{e.abort()})}),[U]),e.useEffect((()=>{const e=Z(j);J(e)}),[j]);const Z=e=>{if(!e)return{};const s={};e.sort(((e,s)=>e.name>s.name?1:-1));for(const a of e){const e=a.name[0].toLocaleUpperCase();s[e]?s[e].push(a):s[e]=[a]}return s},_=(e,s=!1)=>{if(s)X({causes:[],namelike:void 0,region:void 0});else{const s={...U,...e};k.stringify(s)!==k.stringify(U)&&X(s)}},ee=n.jsxs(t,{className:E.formControl,children:[n.jsx(r,{component:"legend",className:$.formLabel,children:"Nonprofits"}),n.jsx(o,{onChange:(e,s)=>{b(s)},value:C,onInputChange:(e,s)=>{_({...U,namelike:s})},popupIcon:!1,PopperComponent:M,clearOnBlur:!1,options:j??[],getOptionLabel:e=>e.name,isOptionEqualToValue:(e,s)=>!0,id:"nonProfitOrgs",renderInput:e=>n.jsx(i,{...e,variant:"standard",placeholder:"Search ..."})})]});return n.jsxs(n.Fragment,{children:[n.jsx(N,{title:"Browsing Nonprofits"}),n.jsx(S,{primaryHeader:"Nonprofits",withDivider:!0}),n.jsx(D,{children:n.jsxs(l,{container:!0,mb:4,className:q.heroContent,children:[n.jsx(l,{item:!0,xs:12,ml:W?0:2,sx:{position:G?"static":"sticky",top:O},children:n.jsx(T,{filterPageLoc:"npoList",flexDirection:"row",queryParams:U,onFilterChange:_})}),n.jsx(l,{item:!0,xs:12,lg:3,sx:{marginLeft:0},children:n.jsxs(c,{style:{position:G?"static":"sticky",top:`calc(${O} + 1.5rem)`},children:[ee,n.jsx(K,{queryParams:U,onFilterChange:_})]})}),n.jsx(l,{item:!0,xs:0,lg:.5}),n.jsx(l,{item:!0,xs:12,lg:8.5,sx:{paddingLeft:Y?2:0},component:"ul",children:j?0===(null==j?void 0:j.length)?n.jsx(B,{header:`Browsing nonprofits near ${P("npoList",U.region)}`,description:"Field Day has begun partnering with select nonprofit partners to support this region,\n please contact us to discuss setting up an Impact campaign.",iconSrc:z.Nonprofit,callToActionLink:"https://www.fieldday.com/companies/impact-campaigns",callToActionText:"Impact campaigns",secondaryCallToActionLink:"https://www.fieldday.com/contact-sales",secondaryCallToActionText:"Contact us",external:!0}):n.jsx(n.Fragment,{children:R.map((([s,a],t)=>n.jsxs(e.Fragment,{children:[n.jsx(m,{variant:"h5",sx:{color:H.palette.primary.dark},mb:3,mt:2,children:s}),a.map(((s,t)=>n.jsxs(e.Fragment,{children:[n.jsx("li",{style:{listStyle:"none"},children:n.jsxs(d,{direction:W?"column":"row",justifyContent:"space-between",alignItems:W?"start":"center",children:[n.jsx(m,{variant:"subhead3B",component:A,to:`/nonprofits/${s.handle}`,sx:{color:`${H.palette.primary.dark} !important`},children:s.name}),n.jsxs(d,{direction:"row",alignItems:"center",mt:W?.5:0,children:[s.primaryCause&&n.jsx(p,{color:"info",size:"small",label:s.primaryCause,sx:{marginLeft:W?0:1.5}}),s.secondaryCause&&n.jsx(p,{color:"info",size:"small",label:s.secondaryCause})]})]})}),t!==a.length-1&&n.jsx(u,{sx:{my:1,borderColor:"rgba(193, 197, 200, .5)"}})]},s.id))),t!==R.length-1&&n.jsx(u,{sx:{mt:5.625}})]},`npos|${s}`)))}):n.jsx(Q,{})})]})})]})}function K({queryParams:e,onFilterChange:s,styleOverride:a}){const l=v(),c=I(),m=E(e.causes);return n.jsxs(n.Fragment,{children:[n.jsxs(t,{className:l.formControl,style:{width:(null==a?void 0:a.width)?null==a?void 0:a.width:""},children:[n.jsx(r,{className:c.formLabel,children:"Cause areas"}),n.jsx(o,{onChange:(a,n)=>{s({...e,causes:n})},multiple:!0,options:f.Causes,value:m,renderOption:(e,s,{selected:a})=>n.jsxs("li",{...e,children:[n.jsx(x,{icon:$,checkedIcon:H,checked:a}),s]}),renderTags:()=>null,disableClearable:!0,renderInput:e=>n.jsx(i,{...e,variant:"standard",placeholder:"Search ..."})})]}),n.jsx(V,{causeAreas:m,removeCause:a=>{(a=>{const n=m.filter((e=>e!==a));s({...e,causes:n})})(a)},clearCauses:()=>s({...e,causes:[]})})]})}const M=e=>n.jsx(h,{open:!1}),Q=()=>{const t=s(),r=a(t.breakpoints.between("sm","lg"));return n.jsx(l,{item:!0,xs:12,sx:{paddingLeft:r?2:0},component:"ul",children:[1,2,3,4,5].map((s=>n.jsx(e.Fragment,{children:n.jsx("li",{style:{listStyle:"none",width:"100%"},children:n.jsx(g,{variant:"rectangular",animation:"wave",height:50,sx:{marginBottom:"10px",borderRadius:"5px",width:"100%"}})})},s)))})};export{K as CausePicker,J as default}; //# sourceMappingURL=ListNonProfits-DAGW9UXN.js.map