import{d as e}from"./objectSpread2-DtFdQpqy.js";import{a as t,n}from"./preload-helper-EQ20WQt-.js";import{c as r,l as i,o as a}from"./prop-types-DdDwMzX7.js";import{Do as o,Eo as s,Wi as c,ja as l,qa as u,z as d}from"./time-BE5vfriQ.js";import{n as f}from"./api-BtDY8vu4.js";import{t as p}from"./helmet-xJbX5x_5.js";import{n as m}from"./short_number-CCNBtmoH.js";import{t as h}from"./column-CvSGioVA.js";import{d as g,t as _}from"./account-xzygKTFE.js";import{a as v}from"./columns_area-GWMCU5jL.js";import{t as y}from"./index.module-TU-jmGO1.js";import{t as b}from"./scrollable_list-BjgHe2e-.js";import{t as x}from"./column_search_header-B612qoy9.js";var S=e(t()),C=n(),w=r({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`}}),T=({multiColumn:e})=>{let t=i(),n=s(),r=o(e=>e.suggestions.isLoading),T=o(e=>e.suggestions.items),[E,D]=(0,S.useState)([]),[O,k]=(0,S.useState)(`remove`),[A,j]=(0,S.useState)(!1),[M,N]=(0,S.useState)(!1);(0,S.useEffect)(()=>(n(d()),()=>{n(c(`home`))}),[n]);let P=(0,S.useCallback)(()=>{k(`add`)},[k]),F=(0,S.useCallback)(()=>{k(`remove`),N(!1)},[k,N]),I=(0,S.useRef)(null),L=y(e=>{if(I.current&&I.current.abort(),e.trim().length===0){N(!1),D([]);return}N(!0),j(!0),I.current=new AbortController,f(`GET`,`v1/accounts/search`,{signal:I.current.signal,params:{q:e}}).then(e=>(n(u(e)),n(l(e.map(e=>e.id))),D(e.map(e=>e.id)),j(!1),``)).catch(()=>{j(!1)})},500,{leading:!0,trailing:!0}),R;return R=O===`add`&&M?E:T.map(e=>e.account_id),(0,C.jsxs)(h,{bindToDocument:!e,label:t.formatMessage(w.title),children:[(0,C.jsx)(v,{title:t.formatMessage(w.title),icon:`person`,iconComponent:g,multiColumn:e}),(0,C.jsx)(x,{placeholder:t.formatMessage(w.search),onBack:F,onActivate:P,active:O===`add`,onSubmit:L}),(0,C.jsx)(b,{scrollKey:`follow_recommendations`,trackScroll:!e,bindToDocument:!e,showLoading:(r||A)&&R.length===0,hasMore:!1,isLoading:r||A,footer:(0,C.jsxs)(C.Fragment,{children:[R.length>0&&(0,C.jsx)(`div`,{className:`spacer`}),(0,C.jsx)(`div`,{className:`column-footer`,children:(0,C.jsx)(m,{className:`button button--block`,to:`/start/profile`,children:(0,C.jsx)(a,{id:`onboarding.follows.next`,defaultMessage:`Next: Setup your profile`})})})]}),emptyMessage:O===`remove`?(0,C.jsx)(a,{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.`}):(0,C.jsx)(a,{id:`lists.no_results_found`,defaultMessage:`No results found.`}),children:R.map(e=>(0,C.jsx)(_,{id:e,withBio:!0,withMenu:!1},e))}),(0,C.jsxs)(p,{children:[(0,C.jsx)(`title`,{children:t.formatMessage(w.title)}),(0,C.jsx)(`meta`,{name:`robots`,content:`noindex`})]})]})};export{T as Follows,T as default};
//# sourceMappingURL=follows-COk0S4Nr.js.map