"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkC5IZ2GUCjs = require('./chunk-C5IZ2GUC.js');var _chunkQY5FWMPEjs = require('./chunk-QY5FWMPE.js');var _chunk5JYVRWWXjs = require('./chunk-5JYVRWWX.js');var _chunk76SYFDGDjs = require('./chunk-76SYFDGD.js');var _chunk6S5LPSJPjs = require('./chunk-6S5LPSJP.js');var _chunkYAUJTS3Ljs = require('./chunk-YAUJTS3L.js');var _chunk4HTAS47Vjs = require('./chunk-4HTAS47V.js');var _chunkPKZQO5SKjs = require('./chunk-PKZQO5SK.js');var _react = require('react');var _authentication = require('@baseapp-frontend/authentication');var _avatars = require('@baseapp-frontend/design-system/components/web/avatars');var _popovers = require('@baseapp-frontend/design-system/components/web/popovers');var _common = require('@baseapp-frontend/design-system/hooks/common');var _Divider = require('@mui/material/Divider'); var _Divider2 = _interopRequireDefault(_Divider);var _jsxruntime = require('react/jsx-runtime');function c(r){"@babel/helpers - typeof";return c=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},c(r)}function G(r,e){var o=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(l){return Object.getOwnPropertyDescriptor(r,l).enumerable})),o.push.apply(o,t)}return o}function i(r){for(var e=1;e<arguments.length;e++){var o=arguments[e]!=null?arguments[e]:{};e%2?G(Object(o),!0).forEach(function(t){oe(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):G(Object(o)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(o,t))})}return r}function oe(r,e,o){return(e=te(e))in r?Object.defineProperty(r,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[e]=o,r}function te(r){var e=ne(r,"string");return c(e)=="symbol"?e:e+""}function ne(r,e){if(c(r)!="object"||!r)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var t=o.call(r,e||"default");if(c(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function ie(r,e){return fe(r)||se(r,e)||ue(r,e)||le()}function le(){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 ue(r,e){if(r){if(typeof r=="string")return J(r,e);var o={}.toString.call(r).slice(8,-1);return o==="Object"&&r.constructor&&(o=r.constructor.name),o==="Map"||o==="Set"?Array.from(r):o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?J(r,e):void 0}}function J(r,e){(e==null||e>r.length)&&(e=r.length);for(var o=0,t=Array(e);o<e;o++)t[o]=r[o];return t}function se(r,e){var o=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(o!=null){var t,l,p,f,a=[],u=!0,s=!1;try{if(p=(o=o.call(r)).next,e===0){if(Object(o)!==o)return;u=!1}else for(;!(u=(t=p.call(o)).done)&&(a.push(t.value),a.length!==e);u=!0);}catch(m){s=!0,l=m}finally{try{if(!u&&o.return!=null&&(f=o.return(),Object(f)!==f))return}finally{if(s)throw l}}return a}}function fe(r){if(Array.isArray(r))return r}var ve=function(e){var o,t,l=e.PopoverStyles,p=l===void 0?{}:l,f=e.MenuItems,a=f===void 0?_chunkC5IZ2GUCjs.a:f,u=e.MenuItemsProps,s=u===void 0?{}:u,m=e.CurrentUser,C=m===void 0?_chunkQY5FWMPEjs.a:m,j=e.CurrentProfile,w=j===void 0?_chunk4HTAS47Vjs.a:j,A=e.SwitchProfileMenu,h=A===void 0?_chunk6S5LPSJPjs.a:A,_=e.SwitchProfileMenuProps,V=_===void 0?{}:_,L=e.ProfilesList,$=L===void 0?_chunkPKZQO5SKjs.a:L,D=e.ProfilesListProps,X=D===void 0?{}:D,x=e.AddProfileMenuItem,T=x===void 0?_chunkYAUJTS3Ljs.a:x,U=e.AddProfileMenuItemProps,Y=U===void 0?{}:U,E=e.LogoutItemProps,Z=E===void 0?{}:E,ee=_authentication.useCurrentProfile.call(void 0, {noSSR:!1}),P=ee.currentProfile,d=_common.usePopover.call(void 0, ),re=_react.useState.call(void 0, !1),k=ie(re,2),v=k[0],g=k[1],y=null,I=function(){d.onClose(),v&&(y=setTimeout(function(){g(!1)},500))};_react.useEffect.call(void 0, function(){return function(){y&&clearTimeout(y)}},[y]);var b=!!w&&!!P,F=!b&&!!C;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _avatars.ClickableAvatar,{color:"secondary",src:(o=_optionalChain([P, 'optionalAccess', _2 => _2.image]))!==null&&o!==void 0?o:"",alt:"User avatar",onClick:d.onOpen,isOpen:!!d.open}),_jsxruntime.jsxs.call(void 0, _popovers.Popover,{open:d.open,onClose:I,sx:i(i({},_chunk76SYFDGDjs.a),p),children:[$&&v?_jsxruntime.jsx.call(void 0, $,i({openSubmenu:v,handleCloseSubmenu:function(){return g(!1)}},X)):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[b&&_jsxruntime.jsx.call(void 0, w,{}),F&&_jsxruntime.jsx.call(void 0, C,{}),b&&!!h&&_jsxruntime.jsx.call(void 0, h,i({openProfilesList:function(){return g(!0)}},V)),!!a&&!!(s!=null&&(t=s.menuItems)!==null&&t!==void 0&&t.length)&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[!!(b||F||h)&&_jsxruntime.jsx.call(void 0, _Divider2.default,{sx:{borderStyle:"solid"}}),_jsxruntime.jsx.call(void 0, a,i({handlePopoverOnClose:I},s))]})]}),!!_chunk5JYVRWWXjs.a&&_jsxruntime.jsx.call(void 0, _Divider2.default,{sx:{borderStyle:"solid"}}),_jsxruntime.jsx.call(void 0, _chunk5JYVRWWXjs.a,i(i({handlePopoverOnClose:I},Z),{},{children:v&&!!T&&_jsxruntime.jsx.call(void 0, T,i({},Y))}))]})]})},_e= exports.a =ve;exports.a = _e;
//# sourceMappingURL=chunk-5W2M3JZU.js.map