import{r as a}from"./vendor-react-DX7tU9aY.js";import{G as x,L as b,j as s,b1 as _,a0 as z,c1 as F,b4 as G,S as N,a7 as O,aT as Q,Z as V,X as o}from"./vendor-mui-core-D7t4vMS5.js";import{W as X,b4 as y}from"./vendor-ux-Dl3wVbv_.js";import"./index-Ca33rdd_.js";import{f as Z}from"./index-DBs9Ljax.js";function H(){const e=x();return{minWidth:b(e.breakpoints.down("md"))?300:e.breakpoints.values.sm}}function I({title:e,description:t,showCancel:c=!0,showConfirm:C=!0,cancel:j="",confirm:k="Confirm",color:w="error",params:D={},onCancel:S=()=>{},onConfirm:T,loading:l=!1,displayError:E=!0,children:P=void 0,...W}){const[r,v]=a.useState(D),[R,d]=a.useState(!0),[m,p]=a.useState(!1),[u,f]=a.useState(""),{t:$}=X(),q=x(),h=async n=>{if(typeof n=="function"){p(!0);try{if(await n(r)===!1)return;d(!1)}catch(i){f(Z(i)),console.error(i)}finally{p(!1)}}else d(!1)},B=typeof e=="function"?e():e,M=typeof t=="function"?t(r,v,f):t,A=b(q.breakpoints.down("md")),L=n=>{n.stopPropagation()},{minWidth:g}=H();return s.jsxs(J,{onClick:L,fullScreen:A,open:R,style:{minWidth:g},...W,children:[s.jsx(_,{children:B}),s.jsxs(z,{style:{minWidth:g},children:[s.jsx(F,{component:"div",children:M}),!!u&&E&&s.jsx(G,{severity:"error",style:{width:"100%",marginTop:8},children:u}),P]}),s.jsxs(N,{className:"delete-actions",style:{padding:"8px 24px 24px"},children:[c&&s.jsx(y,{onClick:n=>{n.stopPropagation(),h(S)},color:"inherit","data-cy":"cancel-confirm-dialog",children:j||$("common.cancel")}),C&&s.jsxs(y,{onClick:n=>{n.stopPropagation(),h(T)},color:w,disabled:r.__disableConfirm||m||l,variant:"contained","data-cy":"submit-confirm-dialog",autoFocus:!0,children:[(m||l)&&s.jsx(O,{size:16,sx:{mr:1}}),k]})]})]})}I.propTypes={title:o.any.isRequired,description:o.any.isRequired,showCancel:o.bool,showConfirm:o.bool,cancel:o.string,color:o.string,confirm:o.string,params:o.object,onCancel:o.func,onConfirm:o.func.isRequired,loading:o.bool,displayError:o.bool,children:o.any};const J=Q(V)`
  .delete-actions .Mui-disabled {
    color: ${({theme:e})=>`${e.palette.text.primary} !important`};
    box-shadow: none;
    background-color: ${({theme:e})=>`${e.palette.action.disabled} !important`};
  }
`;export{I as C};
