import{r}from"./vendor-react-CUXIiAnY.js";import{D as x,J as b,j as t,bC as z,$ as F,bD as J,aX as L,R as N,a6 as O,at as Q,Y as V,W as o}from"./vendor-mui-core-BPQ6AEW_.js";import{V as X,n as y}from"./vendor-ux-r9bApERu.js";import"./index-DY2wgD65.js";import{f as Y}from"./index-DBs9Ljax.js";function G(){const e=x();return{minWidth:b(e.breakpoints.down("md"))?300:e.breakpoints.values.sm}}function H({title:e,description:s,showCancel:l=!0,showConfirm:C=!0,cancel:j="",confirm:k="Confirm",color:D="error",params:w={},onCancel:S=()=>{},onConfirm:E,loading:c=!1,displayError:P=!0,children:R=void 0,...T}){const[a,W]=r.useState(w),[$,d]=r.useState(!0),[m,p]=r.useState(!1),[u,f]=r.useState(""),{t:v}=X(),q=x(),h=async n=>{if(typeof n=="function"){p(!0);try{if(await n(a)===!1)return;d(!1)}catch(i){f(Y(i)),console.error(i)}finally{p(!1)}}else d(!1)},B=typeof e=="function"?e():e,M=typeof s=="function"?s(a,W,f):s,A=b(q.breakpoints.down("md")),_=n=>{n.stopPropagation()},{minWidth:g}=G();return t.jsxs(I,{onClick:_,fullScreen:A,open:$,style:{minWidth:g},...T,children:[t.jsx(z,{children:B}),t.jsxs(F,{style:{minWidth:g},children:[t.jsx(J,{component:"div",children:M}),!!u&&P&&t.jsx(L,{severity:"error",style:{width:"100%",marginTop:8},children:u}),R]}),t.jsxs(N,{className:"delete-actions",style:{padding:"8px 24px 24px"},children:[l&&t.jsx(y,{onClick:n=>{n.stopPropagation(),h(S)},color:"inherit","data-cy":"cancel-confirm-dialog",children:j||v("common.cancel")}),C&&t.jsxs(y,{onClick:n=>{n.stopPropagation(),h(E)},color:D,disabled:a.__disableConfirm||m||c,variant:"contained","data-cy":"submit-confirm-dialog",autoFocus:!0,children:[(m||c)&&t.jsx(O,{size:16,sx:{mr:1}}),k]})]})]})}H.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 I=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{H as C};
