import{a as I}from"./chunk-G2EU2Z7S.mjs";import{a as h}from"./chunk-OMZH2QYB.mjs";import{Iconify as _}from"@baseapp-frontend/design-system/components/web/images";import{useNotification as E}from"@baseapp-frontend/utils";import{Button as L}from"@mui/material";import{useMutation as D,useRelayEnvironment as N}from"react-relay";import{commitLocalUpdate as P}from"relay-runtime";import{jsx as F}from"react/jsx-runtime";function S(o,e){return k(o)||R(o,e)||x(o,e)||U()}function U(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function x(o,e){if(o){if(typeof o=="string")return T(o,e);var t={}.toString.call(o).slice(8,-1);return t==="Object"&&o.constructor&&(t=o.constructor.name),t==="Map"||t==="Set"?Array.from(o):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?T(o,e):void 0}}function T(o,e){(e==null||e>o.length)&&(e=o.length);for(var t=0,l=Array(e);t<e;t++)l[t]=o[t];return l}function R(o,e){var t=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(t!=null){var l,d,f,c,r=[],n=!0,s=!1;try{if(f=(t=t.call(o)).next,e===0){if(Object(t)!==t)return;n=!1}else for(;!(n=(l=f.call(t)).done)&&(r.push(l.value),r.length!==e);n=!0);}catch(v){s=!0,d=v}finally{try{if(!n&&t.return!=null&&(c=t.return(),Object(c)!==c))return}finally{if(s)throw d}}return r}}function k(o){if(Array.isArray(o))return o}var z=function(e){var t=e.targetId,l=e.isFollowedByMe,d=e.currentProfileId,f=e.profileRef,c=D(h),r=S(c,2),n=r[0],s=r[1],v=E(),M=v.sendToast,$=N(),A=function(){s||!d||!t||n({variables:{input:{targetObjectId:t,actorObjectId:d}},onCompleted:function(j,m){var g;if(m?.forEach(function(p){M(p.message,{type:"error"})}),!m){var i=(g=j.followToggle)===null||g===void 0?void 0:g.follow;P($,function(p){var y,a,w,u;if(f!=null){var B=p.readUpdatableFragment(I,f),b=B.updatableData,C=(y=i==null||(a=i.node)===null||a===void 0||(a=a.target)===null||a===void 0?void 0:a.isFollowedByMe)!==null&&y!==void 0?y:!1,O=(w=i==null||(u=i.node)===null||u===void 0||(u=u.target)===null||u===void 0?void 0:u.followersCount)!==null&&w!==void 0?w:b.followersCount-1;b.isFollowedByMe=C,b.followersCount=O}})}}})};return F(L,{onClick:A,startIcon:l?F(_,{icon:"ci:check-all"}):F(_,{icon:"mingcute:add-line"}),variant:l?"soft":"contained",color:l?"inherit":"primary",disabled:s,size:"medium",children:l?"Following":"Follow"})},Y=z;export{Y as a};
//# sourceMappingURL=chunk-352NAGUN.mjs.map