import{j as c}from"./client-By3tlFYA.js";import{r as m,a as k,u as C,m as w}from"./index-TEHZzOO_.js";import{c as b}from"./index-DkCxcZFY.js";import{u as N,h as E,a as h,b7 as x,am as d,aS as B,bG as F,L}from"./useSelectableClick-D9BFU7v4.js";import{J as T}from"./status_quoted-DH_T-OB6.js";const v={narrow:479,openable:759,full:1174},_=s=>{const[u,n]=m.useState(!1);return m.useEffect(()=>{const f=window.matchMedia("(max-width: ".concat(v[s],"px)"));n(f.matches);const l=t=>{n(t.matches)};return f.addEventListener("change",l),()=>{f.removeEventListener("change",l)}},[s,n]),u};function D(s,u="full"){var l;const n="withMobileLayout(".concat((l=s.displayName)!=null?l:s.name,")"),f=t=>{const i=_(u);return c.jsx(s,{matchesBreakpoint:i,...t})};return f.displayName=n,f}const q=k({unfollow:{id:"account.unfollow",defaultMessage:"Unfollow"},unblock:{id:"account.unblock_short",defaultMessage:"Unblock"},unmute:{id:"account.unmute_short",defaultMessage:"Unmute"},follow:{id:"account.follow",defaultMessage:"Follow"},followBack:{id:"account.follow_back",defaultMessage:"Follow back"},followRequest:{id:"account.follow_request",defaultMessage:"Request to follow"},followRequestCancel:{id:"account.follow_request_cancel",defaultMessage:"Cancel request"},editProfile:{id:"account.edit_profile",defaultMessage:"Edit profile"}}),O={...q,...k({followBack:{id:"account.follow_back_short",defaultMessage:"Follow back"},followRequest:{id:"account.follow_request_short",defaultMessage:"Request"},followRequestCancel:{id:"account.follow_request_cancel_short",defaultMessage:"Cancel"},editProfile:{id:"account.edit_profile_short",defaultMessage:"Edit"}})},$=({accountId:s,compact:u,labelLength:n="auto",className:f})=>{const l=C(),t=N(),{signedIn:i}=E(),o=h(g=>s?g.accounts.get(s):void 0),e=h(g=>s?g.relationships.get(s):void 0),M=(e==null?void 0:e.following)||(e==null?void 0:e.requested);m.useEffect(()=>{s&&i&&t(x([s]))},[t,s,i]);const R=m.useCallback(()=>{i||t(d({modalType:"INTERACTION",modalProps:{accountId:s,url:o==null?void 0:o.url}})),!(!e||!s)&&s!==w&&(e.muting?t(B(s)):o&&e.following?t(d({modalType:"CONFIRM_UNFOLLOW",modalProps:{account:o}})):o&&e.requested?t(d({modalType:"CONFIRM_WITHDRAW_REQUEST",modalProps:{account:o}})):e.blocking?t(d({modalType:"CONFIRM_UNBLOCK",modalProps:{account:o}})):t(F(s)))},[t,s,e,o,i]),y=_("narrow"),r=n==="short"||n==="auto"&&y?O:q,p=o!=null&&o.locked?r.followRequest:r.follow;let a;return i?s===w?a=l.formatMessage(r.editProfile):e?e.muting?a=l.formatMessage(r.unmute):e.following?a=l.formatMessage(r.unfollow):e.blocking?a=l.formatMessage(r.unblock):e.requested?a=l.formatMessage(r.followRequestCancel):e.followed_by&&!(o!=null&&o.locked)?a=l.formatMessage(r.followBack):a=l.formatMessage(p):a=c.jsx(L,{}):a=l.formatMessage(p),s===w?c.jsx("a",{href:"/settings/profile",target:"_blank",rel:"noopener",className:b(f,"button button-secondary",{"button--compact":u}),children:a}):c.jsx(T,{onClick:R,disabled:(e==null?void 0:e.blocked_by)||!(e!=null&&e.following||e!=null&&e.requested)&&((o==null?void 0:o.suspended)||!!(o!=null&&o.moved)),secondary:M,compact:u,className:b(f,{"button--destructive":M}),children:a})};export{$ as F,_ as u,D as w};
//# sourceMappingURL=follow_button-BEpAAZcq.js.map
