import{j as e}from"./client-By3tlFYA.js";import{u as C,r as s,a as L}from"./index-TEHZzOO_.js";import{H as y}from"./Helmet-BG0DmkIY.js";import{L as R}from"./short_number-C9zm8Jg6.js";import{c as B}from"./index.module-BtN9VBAa.js";import{S as D}from"./person-C13r8tNn.js";import{u as E,a as S,dl as F,ep as I,eq as q,b7 as H}from"./useSelectableClick-DFE6ksOx.js";import{d as N}from"./api-C8Dh2R2O.js";import{A as _}from"./index-5YLAbn5U.js";import{C as T}from"./column-KuFpKGtG.js";import{C as P}from"./column_header-EmjRMJIw.js";import{C as z}from"./column_search_header-DJVldN6o.js";import{S as G}from"./scrollable_list-_5p4alS8.js";import{M as g}from"./message-CVkQtbZv.js";import"./numbers-BLyy7tyF.js";import"./index-DkCxcZFY.js";import"./relative_timestamp-BOUL06oe.js";import"./ready-DpOgoWSg.js";import"./index-DUY7J2K7.js";import"./skeleton-CwYXpOUk.js";import"./load_locale-B0g6a935.js";import"./index-DiPYjm3h.js";import"./status_quoted-Bnf38BMc.js";import"./counters-O2iLRFgv.js";import"./follow_button-DLEECx1u.js";import"./verified_badge-ByoQ7e4e.js";import"./scroll-BygYx8ga.js";import"./add-CxOAEcXl.js";import"./chevron_left-tY77j9LU.js";import"./unfold_more-Dg1Ay52N.js";import"./index-De2JrXvy.js";import"./scroll_context-BtA-k5hE.js";import"./schedule_idle_task-CDh0madc.js";import"./load_more-akKnXwt3.js";const m=L({title:{id:"onboarding.follows.title",defaultMessage:"Follow people to get started"},search:{id:"onboarding.follows.search",defaultMessage:"Search"},back:{id:"onboarding.follows.back",defaultMessage:"Back"}}),ke=({multiColumn:a})=>{const i=C(),t=E(),h=S(o=>o.suggestions.isLoading),M=S(o=>o.suggestions.items),[j,b]=s.useState([]),[d,n]=s.useState("remove"),[x,p]=s.useState(!1),[w,l]=s.useState(!1);s.useEffect(()=>(t(F()),()=>{t(I("home"))}),[t]);const k=s.useCallback(()=>{n("add")},[n]),A=s.useCallback(()=>{n("remove"),l(!1)},[n,l]),c=s.useRef(null),v=B(o=>{if(c.current&&c.current.abort(),o.trim().length===0){l(!1),b([]);return}l(!0),p(!0),c.current=new AbortController,N("GET","v1/accounts/search",{signal:c.current.signal,params:{q:o}}).then(u=>(t(q(u)),t(H(u.map(f=>f.id))),b(u.map(f=>f.id)),p(!1),"")).catch(()=>{p(!1)})},500,{leading:!0,trailing:!0});let r;return d==="add"&&w?r=j:r=M.map(o=>o.account_id),e.jsxs(T,{bindToDocument:!a,label:i.formatMessage(m.title),children:[e.jsx(P,{title:i.formatMessage(m.title),icon:"person",iconComponent:D,multiColumn:a,showBackButton:!0}),e.jsx(z,{placeholder:i.formatMessage(m.search),onBack:A,onActivate:k,active:d==="add",onSubmit:v}),e.jsx(G,{scrollKey:"follow_recommendations",trackScroll:!a,bindToDocument:!a,showLoading:(h||x)&&r.length===0,hasMore:!1,isLoading:h||x,footer:e.jsxs(e.Fragment,{children:[r.length>0&&e.jsx("div",{className:"spacer"}),e.jsx("div",{className:"column-footer",children:e.jsx(R,{className:"button button--block",to:"/home",children:e.jsx(g,{id:"onboarding.follows.done",defaultMessage:"Done"})})})]}),emptyMessage:d==="remove"?e.jsx(g,{id:"onboarding.follows.empty",defaultMessage:"Unfortunately, no results can be shown right now. You can try using search or browsing the explore page to find people to follow, or try again later."}):e.jsx(g,{id:"lists.no_results_found",defaultMessage:"No results found."}),children:r.map(o=>e.jsx(_,{id:o,withBio:!0,withMenu:!1},o))}),e.jsxs(y,{children:[e.jsx("title",{children:i.formatMessage(m.title)}),e.jsx("meta",{name:"robots",content:"noindex"})]})]})};export{ke as Follows,ke as default};
//# sourceMappingURL=follows-Djo4HOkv.js.map
