!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],t):"object"==typeof exports?exports["openstack-uicore-foundation"]=t():e["openstack-uicore-foundation"]=t()}(this,(()=>(()=>{"use strict";var e={6031:e=>{e.exports=require("@babel/runtime/helpers/extends")},2462:e=>{e.exports=require("@babel/runtime/helpers/objectWithoutProperties")},8619:e=>{e.exports=require("@mui/material")},9825:e=>{e.exports=require("prop-types")},2015:e=>{e.exports=require("react")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,r),a.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var o={};r.r(o),r.d(o,{default:()=>f});var n=r(6031),a=r.n(n),l=r(2462),i=r.n(l),u=r(2015),s=r.n(u),d=r(9825),p=r.n(d),c=r(8619);const b=["buttonId","menuId","menuItems","hasBadge","children"],m=e=>{let{buttonId:t,menuId:r,menuItems:o,hasBadge:n,children:l}=e,d=i()(e,b);const[p,m]=(0,u.useState)(null),[f,x]=(0,u.useState)([]),g=()=>{m(null)},y=n?f.length:void 0;return s().createElement(s().Fragment,null,s().createElement(c.Button,a()({id:t,"aria-controls":p?r:void 0,"aria-haspopup":"true","aria-expanded":p?"true":void 0,onClick:e=>{m(e.currentTarget)},sx:{color:p?"--variant-textColor":"#000"}},d),n?s().createElement(c.Badge,{badgeContent:y,sx:{"& .MuiBadge-badge":{backgroundColor:"black",color:"white",right:"65%"}}},l):l),s().createElement(c.Menu,{id:r,anchorEl:p,open:Boolean(p),onClose:g,MenuListProps:{"aria-labelledby":t},slotProps:{paper:{sx:{minWidth:220}}}},o.map((e=>{const t=n&&f.includes(e.label);return s().createElement(c.MenuItem,{key:`${e.label}`,onClick:()=>(e=>{if(n){const t=f.includes(e.label)?f.filter((t=>t!==e.label)):[...f,e.label];e.onClick(),x(t)}e.onClick(),g()})(e),sx:{borderBottom:1,borderColor:"divider","&:last-of-type":{borderBottom:0},color:t?"--variant-textColor":"#000"}},e.label)}))))};m.propTypes={buttonId:p().string,menuId:p().string,menuItems:p().array.isRequired,hasBadge:p().bool};const f=m;return o})()));
//# sourceMappingURL=menu-button.js.map