import{j as e,Q as m,R as h}from"./vendor-mui-CBBEb17G.js";import{a as c}from"./vendor-react-BBazpZul.js";import{I as s}from"./index-DdWwwZXu.js";const d=c.createContext(null),I=({children:r})=>{const[n,a]=c.useState(null),i=!!n,o=()=>{a(null)},l=t=>{t.preventDefault(),t.stopPropagation(),a(t.currentTarget)},x={functions:{handleCloseAction:o}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:t=>l(t),children:e.jsx(s.MoreVertical,{color:"action"})}),e.jsx(m,{anchorEl:n,open:i,onClose:o,children:e.jsx(d.Provider,{value:x,children:r})})]})},j=()=>c.useContext(d),g=({submitFunc:r,actionsType:n,label:a,disabled:i})=>{const[o,l]=c.useState(!1),{functions:{handleCloseAction:x}}=j(),t=u=>{u.stopPropagation(),u.preventDefault(),l(!0),r().then(()=>l(!1)),x()};return e.jsx(h,{onClick:t,disabled:i||o,children:e.jsxs("div",{className:"px-8 text-center relative",children:[e.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2",children:o?e.jsx(s.Loader,{className:"animate-spin"}):n==="ADD"&&e.jsx(s.AddIcon,{color:"action",fontSize:"large",className:"mx-1"})||n==="EDIT"&&e.jsx(s.EditIcon,{color:"action",fontSize:"large",className:"mx-1"})||n==="DELETE"&&e.jsx(s.DeleteIcon,{color:"action",fontSize:"large",className:"mx-1"})}),a]})})};export{I,g as M};
