'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../components/Notifications.js"),r=require("react"),o=require("@gem-sdk/core");const s=()=>document.body;let n=0;exports.default=function(c){let{getContainer:u=s,maxCount:a,onAllRemoved:i,...l}=c??{},f=o.useId(),[d,y]=r.useState(),p=r.useRef(null),k=r.useMemo(()=>e.jsx(t.default,{ref:p,container:d,maxCount:a,onAllRemoved:i}),[d,a,i]),[m,b]=r.useState([]),h=r.useMemo(()=>({open:e=>{let t=function(...e){let t={};return e.forEach(e=>{e&&Object.keys(e).forEach(r=>{let o=e[r];void 0!==o&&(t[r]=o)})}),t}(l,e);(null===t.key||void 0===t.key)&&(t.key=`${f}-${n}`,n+=1),r.startTransition(()=>{b(e=>[...e,{type:"open",config:t}])})},close:e=>{r.startTransition(()=>{b(t=>[...t,{type:"close",key:e}])})},destroy:()=>{r.startTransition(()=>{b(e=>[...e,{type:"destroy"}])})}}),[l,f]);return r.useEffect(()=>{y(u())},[u]),r.useEffect(()=>{p.current&&m.length&&(m.forEach(e=>{switch(e.type){case"open":p.current?.open(e.config);break;case"close":p.current?.close(e.key);break;case"destroy":p.current?.destroy()}}),b(()=>[]))},[m]),[h,k]};
