import{r as i,dv as B,U as p,j as e,bA as m,b5 as C,eJ as L,by as v,eK as A,br as f,eL as I}from"./index-DQhyMeoV.js";import{B as z}from"./ButtonGroup-83J5hh2q.js";function P(t,s){i.useEffect(()=>{function r(o){!t||!t.current||t.current.contains(o.target)||s(o)}return document.addEventListener("click",r,!0),()=>{document.removeEventListener("click",r,!0)}},[t,s])}function w({...t}){const{size:s="medium",color:r="primary",menu:o=[],children:c=null,variant:x="contained",onClick:h=B,menuButtonProps:g={},...j}=t,[k,l]=i.useState(!1),a=i.useRef(null),u=i.useRef(null),y=Array.isArray(o)?o.map((n,M)=>i.isValidElement(n)?n:i.createElement(p,{...n,key:M})):o,b=()=>{l(n=>!n)},d=n=>{a.current&&a.current.contains(n.target)||l(!1)};P(u,d);const E=n=>{n.target.closest(".MuiMenuItem-root")&&l(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(R,{variant:x,size:s,color:r,ref:a,...j,children:[typeof c=="function"?c():e.jsx(m,{onClick:h,color:r,children:c}),e.jsx(m,{onClick:b,color:r,...g,"aria-label":"more functions",children:e.jsx(C,{})})]}),e.jsx(V,{open:k,anchorEl:a.current,placement:"bottom-end",disablePortal:!1,children:e.jsx(L,{ref:u,children:e.jsx(v,{onClickAway:d,children:e.jsx(A,{onClick:E,children:y})})})})]})}w.Item=p;const R=f(z)`
  > .MuiButtonBase-root:last-of-type {
    min-width: 2em;
    padding-left: 0;
    padding-right: 0;
  }
`,V=f(I)`
  z-index: ${t=>t.theme.zIndex.tooltip};
  .MuiList-root {
    padding: 4px 0;
  }
  .MuiListItem-root {
    padding-top: 4px;
    padding-bottom: 4px;
  }
`;export{w as O};
