import{a as Q,b as q,c as G}from"./chunk-UR6NEUTE.mjs";import{b as K}from"./chunk-XOCJ3HXP.mjs";import{c as y,d as S,e as O,f as N}from"./chunk-BQRERWAL.mjs";import{a as P}from"./chunk-6U7AQRRM.mjs";import{a as F}from"./chunk-KY323GRB.mjs";import{b as z}from"./chunk-3MNZ55OF.mjs";import{useState as X}from"react";import{useCurrentProfile as Ae}from"@baseapp-frontend/authentication";import{AvatarWithPlaceholder as Te}from"@baseapp-frontend/design-system/components/web/avatars";import{ConfirmDialog as Y}from"@baseapp-frontend/design-system/components/web/dialogs";import{Box as j,Button as _,MenuItem as Ee,Typography as M,useTheme as xe}from"@mui/material";import{useFragment as Be}from"react-relay";import{jsx as i,jsxs as w}from"react/jsx-runtime";function p(r){"@babel/helpers - typeof";return p=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},p(r)}function J(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 Ce(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?J(Object(t),!0).forEach(function(n){Pe(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):J(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function Pe(r,e,t){return(e=Se(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Se(r){var e=Oe(r,"string");return p(e)=="symbol"?e:e+""}function Oe(r,e){if(p(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e||"default");if(p(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function g(r,e){return Ie(r)||we(r,e)||_e(r,e)||je()}function je(){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 _e(r,e){if(r){if(typeof r=="string")return V(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)?V(r,e):void 0}}function V(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 we(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,c,d,b,s=[],l=!0,h=!1;try{if(d=(t=t.call(r)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=d.call(t)).done)&&(s.push(n.value),s.length!==e);l=!0);}catch(R){h=!0,c=R}finally{try{if(!l&&t.return!=null&&(b=t.return(),Object(b)!==b))return}finally{if(h)throw c}}return s}}function Ie(r){if(Array.isArray(r))return r}var $e=function(e){var t,n,c,d,b=e.member,s=e.memberRole,l=e.status,h=e.avatarProps,R=h===void 0?{}:h,I=e.avatarWidth,Z=I===void 0?40:I,A=e.avatarHeight,ee=A===void 0?40:A,T=e.canChangeMember,re=T===void 0?!1:T,f=e.userId,E=e.searchQuery,te=xe(),a=Be(F,b),ne=Ae(),o=ne.currentProfile,oe=z(),x=g(oe,2),ie=x[0],ae=x[1],le=K(),B=g(le,2),ue=B[0],me=B[1],ce=X(!1),$=g(ce,2),se=$[0],C=$[1],fe=X(!1),k=g(fe,2),D=k[0],U=k[1];if(!a)return null;var ve=l===y.active&&s!=="owner"&&re,de=s&&l,be=function(){o!=null&&o.id&&f&&ue({variables:{input:{profileId:o.id,userId:f}}})},he=function(){o!=null&&o.id&&f&&be(),U(!1)},L=function(){U(!D)},W=function(u){o!=null&&o.id&&f&&ie({variables:{input:{profileId:o.id,userId:f,roleType:u}}})},pe=function(u){if(u.target.value===S.admin){C(!0);return}if(o!=null&&o.id&&f){var m;W(u==null||(m=u.target)===null||m===void 0?void 0:m.value)}},ye=function(){C(!1)},ge=function(){o!=null&&o.id&&f&&W(S.admin),C(!1)},Me=function(){return ve?i(j,{children:i(G,{value:s,onChange:function(m,H){var Re=m.target.value;Re===O.remove?L():pe(m)},displayEmpty:!0,variant:"filled",size:"small",disabled:ae||me,children:N.map(function(u){var m=u.value,H=u.label;return i(Ee,{value:m,sx:{color:m===O.remove?te.palette.error.main:"inherit"},children:H},m)})})}):de?i(j,{children:i(_,{variant:"outlined",color:"inherit",sx:{pointerEvents:"none"},children:l===y.active?P(s):P(l)})}):null};return E&&!(a!=null&&(t=a.name)!==null&&t!==void 0&&t.toLowerCase().includes(E.toLowerCase()))?null:w(Q,{children:[i(Y,{title:"Change user permissions?",open:se,action:i(_,{variant:"contained",color:"inherit",onClick:ge,children:"Confirm"}),onClose:ye,content:i(M,{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"}),i(Y,{title:"Remove member",open:D,onClose:L,content:i(M,{variant:"body1",children:"Are you sure you want to remove this member? This action will revoke their access to the organization profile."}),cancelText:"Back",action:i(_,{variant:"contained",color:"error",onClick:he,children:"Remove"})}),w(q,{isActive:l===y.active||!1,children:[i(Te,Ce({width:Z,height:ee,src:(n=a==null||(c=a.image)===null||c===void 0?void 0:c.url)!==null&&n!==void 0?n:"",alt:"Profile avatar",color:"secondary"},R)),w(j,{children:[i(M,{variant:"subtitle2",children:a.name}),i(M,{variant:"caption",children:a==null||(d=a.urlPath)===null||d===void 0?void 0:d.path})]})]}),Me()]})},Ge=$e;export{Ge as a};
//# sourceMappingURL=chunk-JXQ4W346.mjs.map