import{j as n,h as j,H as l,aB as x}from"./vendor-ClLR6ncd.js";import{D as d,a as f,b as h}from"./DialogContent-DR8Wx7Lo.js";import{D}from"./DialogTitle-i0lt2jWQ.js";const p=()=>{};function b({children:s,...e}){return n.jsx(x,{...e,component:"form",children:s})}function v({onSubmit:s,disabledCancel:e,disabledSubmit:r,submitButtonLabel:t,extraDialogActions:a,onClose:i,children:o,...c}){return n.jsxs(d,{PaperComponent:b,PaperProps:{onSubmit:s},onClose:i,...c,children:[o,n.jsxs(h,{children:[n.jsx(l,{disabled:e,onClick:i,children:"Cancel"}),a,n.jsx(l,{type:"submit",variant:"contained",disabled:r,children:t})]})]})}function I({dialogContext:s,mutation:e,submitTitle:r,dialogBodyMessage:t,mutationParameterBuilder:a}){const i=()=>{s.close(),e.reset()},o=()=>{s.cancel(),e.reset()};return n.jsx(g,{...s,close:e.isIdle?p:i,cancel:o,onSubmit:e.isIdle?()=>e.mutate(a(s)):p,submitTitle:e.isIdle?r:"OK",isDisabledSubmit:e.isLoading,dialogTitle:"Confirmation",dialogBodyMessage:t})}const P={component:"form"};function g({isOpen:s,isDisabledSubmit:e,cancel:r,close:t,dialogTitle:a,dialogBodyMessage:i,cancelTitle:o="Cancel",submitTitle:c,onSubmit:m}){return n.jsxs(d,{open:s,onClose:r,PaperProps:P,onSubmit:u=>{u.preventDefault(),m(),t()},children:[n.jsx(D,{children:a}),n.jsx(f,{children:typeof i=="string"?n.jsx(j,{children:i}):i}),n.jsxs(h,{children:[o?n.jsx(l,{onClick:r,color:"inherit",children:o}):null,n.jsx(l,{type:"submit",variant:"contained",disabled:e,children:c})]})]})}export{g as D,v as F,I as a};
