import{a as I}from"./chunk-OLBTMLJ6.mjs";import{a as S}from"./chunk-PJQWPBLU.mjs";import{a as M}from"./chunk-KB7MTR2H.mjs";import{a as N,b as k}from"./chunk-SG5QMJHR.mjs";import{a as j,b as w}from"./chunk-4HKQPKIC.mjs";import{Suspense as X,useMemo as $}from"react";import{useCurrentProfile as ee}from"@baseapp-frontend/authentication";import{ChevronIcon as te}from"@baseapp-frontend/design-system/components/web/icons";import{useNotification as ne}from"@baseapp-frontend/utils";import{Box as d,ButtonBase as re,Divider as oe,Slide as ie}from"@mui/material";import{useLazyLoadQuery as ae,usePaginationFragment as ue}from"react-relay";import{Virtuoso as le}from"react-virtuoso";import{jsx as i,jsxs as H}from"react/jsx-runtime";function m(t){"@babel/helpers - typeof";return m=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},m(t)}function E(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),n.push.apply(n,o)}return n}function L(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E(Object(n),!0).forEach(function(o){W(t,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(n,o))})}return t}function W(t,e,n){return(e=Y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Y(t){var e=Z(t,"string");return m(e)=="symbol"?e:e+""}function Z(t,e){if(m(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var o=n.call(t,e||"default");if(m(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var se=function(e){var n,o=e.handleCloseSubmenu,l=e.MenuItemProps,v=e.LoadingStateProps,x=v===void 0?{}:v,C=e.listMaxHeight,g=C===void 0?300:C,D={count:10},_=ae(j,D,{fetchPolicy:"store-and-network"}),F=_.me,R=ne(),T=R.sendToast,O=ee(),y=O.currentProfile,z=O.setCurrentProfile,B=function(r){if(y?.id!==r.id){var u,c,f,h,P,J=(u=process.env.NEXT_PUBLIC_API_BASE_URL)===null||u===void 0?void 0:u.replace("/v1",""),U=r.image?"".concat(J).concat((c=r.image)===null||c===void 0?void 0:c.url):null;z({id:r.id,name:(f=r.name)!==null&&f!==void 0?f:null,image:U,urlPath:(h=(P=r.urlPath)===null||P===void 0?void 0:P.path)!==null&&h!==void 0?h:null}),T("Switched to ".concat(r.name)),o()}},p=ue(w,F),s=p.data,Q=p.loadNext,V=p.isLoadingNext,A=p.hasNext,b=$(function(){var a;return(s==null||(a=s.profiles)===null||a===void 0?void 0:a.edges.filter(function(r){return r?.node}).map(function(r){return r?.node}))||[]},[s==null||(n=s.profiles)===null||n===void 0?void 0:n.edges]),K=function(){return V?i(S,L({sx:{paddingTop:3},CircularProgressProps:{size:15}},x)):i(d,{sx:{paddingTop:3}})},q=function(r,u){return r?i(M,L({profileRef:r,onProfileChange:B},l),"profile-".concat(u)):null},G=function(){if(b.length===0)return i(I,{});var r=b.length*56>g?g:b.length*56;return i(d,{sx:{backgroundColor:"common.white"},children:i(le,{data:b,style:{height:"auto",minHeight:r},itemContent:function(c,f){return q(f,c)},components:{Footer:K},endReached:function(){A&&Q(10)}})})};return i(d,{children:i(N,{disablePadding:!0,maxHeight:g,"aria-label":"List of available profiles",children:G()})})},de=function(e){var n=e.openSubmenu,o=e.handleCloseSubmenu,l=e.cancelLabel,v=l===void 0?"Cancel":l;return i(ie,{direction:n?"left":"right",in:n,mountOnEnter:!0,unmountOnExit:!0,children:H(d,{children:[i(d,{sx:{p:1},children:H(k,{tabIndex:0,component:re,onClick:function(){return o()},children:[i(te,{position:"left",color:"action"}),v]})}),i(oe,{sx:{borderStyle:"solid"}}),i(d,{sx:{p:1},children:i(X,{fallback:i(S,{}),children:i(se,L({},e))})})]})})},Ce=de;export{Ce as a};
//# sourceMappingURL=chunk-73ETP77I.mjs.map