'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),React=require("react"),reactDom=require("react-dom"),core=require("@gem-sdk/core"),Notice=require("./Notice.js");const Notifications=React.forwardRef((e,t)=>{let{container:r,maxCount:o}=e,[l,i]=React.useState([]),s=React.useCallback(e=>{let t=l.find(t=>t.key===e);t?.onClose?.(),i(t=>t.filter(t=>t.key!==e))},[l]);React.useImperativeHandle(t,()=>({open:e=>{i(t=>{let r=[...t],l=r.findIndex(t=>t.key===e.key);return l>=0?r[l]=e:r.push(e),o&&r.length>o&&(r=r.slice(-o)),r})},close:e=>{s(e)},destroy:()=>{i([])}}),[o,s]);let c=React.useMemo(()=>{let e={};return l.forEach(t=>{let{placement:r="top-right"}=t;e[r]=[...e[r]||[],t]}),e},[l]);if(!r)return null;let p=jsxRuntime.jsx(jsxRuntime.Fragment,{children:Object.keys(c).map(e=>{let t=c[e];return jsxRuntime.jsx("div",{style:{zIndex:9999999},className:core.cls("gp-fixed gp-flex gp-max-h-screen gp-items-end gp-gap-2",{"gp-left-1/2 gp-top-4 -gp-translate-x-1/2 gp-flex-col":"top"===e,"gp-bottom-4 gp-left-1/2 -gp-translate-x-1/2 gp-flex-col":"bottom"===e,"gp-left-4 gp-top-4 gp-flex-col":"top-left"===e,"gp-right-4 gp-top-4 gp-flex-col":"top-right"===e,"gp-bottom-4 gp-left-4 gp-flex-col-reverse":"bottom-left"===e,"gp-bottom-4 gp-right-4 gp-flex-col-reverse":"bottom-right"===e}),children:t?.map(e=>{let{key:t,...r}=e;return jsxRuntime.jsx(Notice.default,{eventKey:t,...r,onNoticeClose:s},t)})},e)})});return reactDom.createPortal(p,r)});Notifications.displayName="Notifications",exports.default=Notifications;
