import e from"../_util/classNames.mjs";import{getTransitionGroupProps as t}from"../_util/transition.mjs";import n from"../_util/Portal.mjs";import r from"./Notice.mjs";import{TransitionGroup as i,computed as a,createVNode as o,defineComponent as s,ref as c,watch as l}from"vue";var u=0,d=Date.now();function f(){let e=u;return u+=1,`rcNotification_${d}_${e}`}var p=s({name:`HookNotification`,inheritAttrs:!1,props:[`prefixCls`,`transitionName`,`animation`,`maxCount`,`closeIcon`,`hashId`,`remove`,`notices`,`getStyles`,`getClassName`,`onAllRemoved`,`getContainer`],setup(s,{attrs:u,slots:d}){let f=new Map,p=a(()=>s.notices),m=a(()=>{let e=s.transitionName;if(!e&&s.animation)switch(typeof s.animation){case`string`:e=s.animation;break;case`function`:e=s.animation().name;break;case`object`:e=s.animation.name;break;default:e=`${s.prefixCls}-fade`;break}return t(e)}),h=e=>s.remove(e),g=c({});l(p,()=>{let e={};Object.keys(g.value).forEach(t=>{e[t]=[]}),s.notices.forEach(t=>{let{placement:n=`topRight`}=t.notice;n&&(e[n]=e[n]||[],e[n].push(t))}),g.value=e});let _=a(()=>Object.keys(g.value));return()=>{let{prefixCls:t,closeIcon:a=d.closeIcon?.({prefixCls:t})}=s,c=_.value.map(n=>{let c=g.value[n],l=s.getClassName?.(n),d=s.getStyles?.(n),_=c.map(({notice:n,holderCallback:i},c)=>{let l=c===p.value.length-1?n.updateMark:void 0,{key:u,userPassKey:d}=n,{content:m}=n,g={prefixCls:t,closeIcon:typeof a==`function`?a({prefixCls:t}):a,...n,...n.props,key:u,noticeKey:d||u,updateMark:l,onClose:e=>{h(e),n.onClose?.()},onClick:n.onClick};return i?o(`div`,{key:u,class:`${t}-hook-holder`,ref:e=>{u!==void 0&&(e?(f.set(u,e),i(e,g)):f.delete(u))}},null):o(r,{...g,class:e(g.class,s.hashId)},{default:()=>[typeof m==`function`?m({prefixCls:t}):m]})}),v={[t]:1,[`${t}-${n}`]:1,[u.class]:!!u.class,[s.hashId]:!0,[l]:!!l};function y(){c.length>0||(Reflect.deleteProperty(g.value,n),s.onAllRemoved?.())}return o(`div`,{key:n,class:v,style:u.style||d||{top:`65px`,left:`50%`}},[o(i,{tag:`div`,...m.value,onAfterLeave:y},{default:()=>[_]})])});return o(n,{getContainer:s.getContainer},{default:()=>[c]})}}});export{p as default,f as getUuid};