import{M as p,j as e,R as m,bR as C,P as b,aj as B,p as L,bI as v,Q as P}from"./vendor-mui-core-CDEc-eG6.js";import{r as i}from"./vendor-react-DX7tU9aY.js";import{n as R}from"./vendor-utils-_C9URqjS.js";import{l as f}from"./vendor-ux-PO0jFgJf.js";function z(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 A({...t}){const{size:s="medium",color:r="primary",menu:o=[],children:c=null,variant:x="contained",onClick:h=R,menuButtonProps:j={},...g}=t,[k,l]=i.useState(!1),a=i.useRef(null),u=i.useRef(null),M=Array.isArray(o)?o.map((n,I)=>i.isValidElement(n)?n:i.createElement(p,{...n,key:I})):o,y=()=>{l(n=>!n)},d=n=>{a.current&&a.current.contains(n.target)||l(!1)};z(u,d);const E=n=>{n.target.closest(".MuiMenuItem-root")&&l(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(w,{variant:x,size:s,color:r,ref:a,...g,children:[typeof c=="function"?c():e.jsx(m,{onClick:h,color:r,children:c}),e.jsx(m,{onClick:y,color:r,...j,"aria-label":"more functions",children:e.jsx(C,{})})]}),e.jsx(V,{open:k,anchorEl:a.current,placement:"bottom-end",disablePortal:!1,children:e.jsx(b,{ref:u,children:e.jsx(B,{onClickAway:d,children:e.jsx(L,{onClick:E,children:M})})})})]})}A.Item=p;const w=f(v)`
  > .MuiButtonBase-root:last-of-type {
    min-width: 2em;
    padding-left: 0;
    padding-right: 0;
  }
`,V=f(P)`
  z-index: ${t=>t.theme.zIndex.tooltip};
  .MuiList-root {
    padding: 4px 0;
  }
  .MuiListItem-root {
    padding-top: 4px;
    padding-bottom: 4px;
  }
`;export{A as O};
