import{R as e,j as P}from"./vendor-ClLR6ncd.js";import{D as g}from"./lodash-ZyeDnt0e.js";function d(){const s=e.createContext(),i=()=>e.useContext(s);function l({children:p,initParameterValue:n}){const[m,r]=e.useState(!1),t=e.useRef(null),[a,o]=e.useState(n),f=R=>{t.current=Promise.withResolvers(),r(!0),o(R)},c=()=>{if(!t.current)throw new Error("unsupported flow. promiseRef must not be null on closing dialog");t.current.resolve(!1),r(!1)},u=()=>{o(n)},x=()=>{u(),c()},C={isOpen:m,openParameter:a,isOpenParameterSet:!g(a),promiseRef:t,open:f,close:c,cancel:x,setOpenParameter:o,resetOpenParameter:u};return P.jsx(s.Provider,{value:C,children:p})}return{useDialogContext:i,DialogContextProvider:l}}export{d as C};
