"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("../../../_virtual/jsx-runtime.js"),t=require("react"),E=require("react-dom"),x=require("../../../utils/index.js"),_=require("./components/MessageProviderToast.js"),s=require("./constants.js"),n=require("./reducer.js"),g=require("./styles.js"),o=require("./utils/createMessageMethods.js");const u=t.createContext(s.INITIAL_MESSAGE_CONTEXT_VALUE),A=()=>t.useContext(u),O={action:"acknowledge",autoHideDuration:s.AUTO_HIDE_DURATION_DEFAULT,position:s.MESSAGE_POSITION_DEFAULT,toastType:s.TOAST_TYPE_COMPACT,zIndex:6e3};function P({children:c,messageRoot:d,options:T}){const[M,r]=t.useReducer(n.messagesReducer,n.initialMessagesState),e={...O,...T},p=t.useMemo(()=>({compact:o.createMessageMethods(r,{...e,toastType:s.TOAST_TYPE_COMPACT}),default:o.createMessageMethods(r,{...e,toastType:s.TOAST_TYPE_DEFAULT}),...o.createMessageMethods(r,e)}),[]),v=t.useRef(x.getComponentRoot(d));return i.jsxRuntimeExports.jsxs(u.Provider,{value:p,children:[c,E.createPortal(i.jsxRuntimeExports.jsx(g.ToastWrapper,{position:e.position,zIndex:e.zIndex,children:M.messages.map(a=>t.createElement(_.MessageProviderToast,{...a,key:a.id,position:e.position}))}),v.current)]})}exports.MessageProvider=P;exports.useMessageContext=A;
