import{M as p,j as e,Q as m,b0 as I,P as b,ai as B,o as L,bV as v,O as P}from"./vendor-mui-core-CKKG_1TN.js";import{r as i}from"./vendor-react-CTtPmzVP.js";import{n as z}from"./vendor-utils-CUs2ebe7.js";import{l as f}from"./vendor-ux-DjXlxcvL.js";function A(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=z,menuButtonProps:g={},...j}=t,[k,l]=i.useState(!1),a=i.useRef(null),u=i.useRef(null),M=Array.isArray(o)?o.map((n,C)=>i.isValidElement(n)?n:i.createElement(p,{...n,key:C})):o,y=()=>{l(n=>!n)},d=n=>{a.current&&a.current.contains(n.target)||l(!1)};A(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:y,color:r,...g,"aria-label":"more functions",children:e.jsx(I,{})})]}),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})})})})]})}w.Item=p;const R=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{w as O};
