import{a as D,b as L,c as W}from"./chunk-UR6NEUTE.mjs";import{c as y,d as j,e as B}from"./chunk-BHP27HO3.mjs";import{a as C}from"./chunk-6U7AQRRM.mjs";import{a as U}from"./chunk-KY323GRB.mjs";import{b as E}from"./chunk-3MNZ55OF.mjs";import{useState as de}from"react";import{useCurrentProfile as ve}from"@baseapp-frontend/authentication";import{AvatarWithPlaceholder as he}from"@baseapp-frontend/design-system/components/web/avatars";import{ConfirmDialog as be}from"@baseapp-frontend/design-system/components/web/dialogs";import{Box as O,Button as z,MenuItem as pe,Typography as R}from"@mui/material";import{useFragment as ye}from"react-relay";import{jsx as i,jsxs as S}from"react/jsx-runtime";function h(r){"@babel/helpers - typeof";return h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h(r)}function k(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(c){return Object.getOwnPropertyDescriptor(r,c).enumerable})),t.push.apply(t,n)}return t}function ie(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?k(Object(t),!0).forEach(function(n){ae(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):k(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function ae(r,e,t){return(e=le(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function le(r){var e=ue(r,"string");return h(e)=="symbol"?e:e+""}function ue(r,e){if(h(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e||"default");if(h(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function H(r,e){return fe(r)||se(r,e)||me(r,e)||ce()}function ce(){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 me(r,e){if(r){if(typeof r=="string")return F(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?F(r,e):void 0}}function F(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function se(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,c,f,d,m=[],a=!0,v=!1;try{if(f=(t=t.call(r)).next,e===0){if(Object(t)!==t)return;a=!1}else for(;!(a=(n=f.call(t)).done)&&(m.push(n.value),m.length!==e);a=!0);}catch(g){v=!0,c=g}finally{try{if(!a&&t.return!=null&&(d=t.return(),Object(d)!==d))return}finally{if(v)throw c}}return m}}function fe(r){if(Array.isArray(r))return r}var ge=function(e){var t,n,c,f,d=e.member,m=e.memberRole,a=e.status,v=e.avatarProps,g=v===void 0?{}:v,w=e.avatarWidth,K=w===void 0?40:w,M=e.avatarHeight,Q=M===void 0?40:M,_=e.canChangeMember,N=_===void 0?!1:_,b=e.userId,I=e.searchQuery,o=ye(U,d),q=ve(),l=q.currentProfile,G=E(),A=H(G,2),J=A[0],V=A[1],X=de(!1),T=H(X,2),Y=T[0],P=T[1];if(!o)return null;var Z=a===y.active&&m!=="owner"&&N,ee=m&&a,x=function(u){l!=null&&l.id&&b&&J({variables:{input:{profileId:l.id,userId:b,roleType:u}}})},re=function(u){if(u.target.value===j.admin){P(!0);return}if(l!=null&&l.id&&b){var s;x(u==null||(s=u.target)===null||s===void 0?void 0:s.value)}},te=function(){P(!1)},ne=function(){l!=null&&l.id&&b&&x(j.admin),P(!1)},oe=function(){return Z?i(O,{children:i(W,{value:m,onChange:function(s,$){return re(s)},displayEmpty:!0,variant:"filled",size:"small",disabled:V,children:B.map(function(u){var s=u.value,$=u.label;return i(pe,{value:s,children:$},s)})})}):ee?i(O,{children:i(z,{variant:"soft",color:"inherit",sx:{pointerEvents:"none"},children:a===y.active?C(m):C(a)})}):null};return I&&!(o!=null&&(t=o.name)!==null&&t!==void 0&&t.toLowerCase().includes(I.toLowerCase()))?null:S(D,{children:[i(be,{title:"Change user permissions?",open:Y,action:i(z,{variant:"contained",color:"inherit",onClick:ne,children:"Confirm"}),onClose:te,content:i(R,{variant:"body1",children:"Are you sure you want to promote this member to an admin? They will have full administrative rights, including the ability to manage members and settings."}),cancelText:"Back"}),S(L,{isActive:a===y.active||!1,children:[i(he,ie({width:K,height:Q,src:(n=o==null||(c=o.image)===null||c===void 0?void 0:c.url)!==null&&n!==void 0?n:"",alt:"Profile avatar",color:"secondary"},g)),S(O,{children:[i(R,{variant:"subtitle2",children:o.name}),i(R,{variant:"caption",children:o==null||(f=o.urlPath)===null||f===void 0?void 0:f.path})]})]}),oe()]})},Te=ge;export{Te as a};
//# sourceMappingURL=chunk-H3AKUSDZ.mjs.map