import e,{getUuid as t}from"./HookNotification.mjs";import{createVNode as n,shallowRef as r,watch as i}from"vue";var a=()=>document.body,o=0;function s(...e){let t={};return e.forEach(e=>{e&&Object.keys(e).forEach(n=>{let r=e[n];r!==void 0&&(t[n]=r)})}),t}function c(c={}){let{getContainer:l=a,motion:u,prefixCls:d,maxCount:f,getClassName:p,getStyles:m,onAllRemoved:h,...g}=c,_=r([]),v=r(),y=(e,n)=>{let r=e.key||t(),i={...e,key:r},a=_.value.map(e=>e.notice.key).indexOf(r),o=_.value.concat();a===-1?(f&&_.value.length>=f&&(i.key=o[0].notice.key,i.updateMark=t(),i.userPassKey=r,o.shift()),o.push({notice:i,holderCallback:n})):o.splice(a,1,{notice:i,holderCallback:n}),_.value=o},b=e=>{_.value=_.value.filter(({notice:{key:t,userPassKey:n}})=>(n||t)!==e)},x=()=>{_.value=[]},S=()=>n(e,{ref:v,prefixCls:d,maxCount:f,notices:_.value,remove:b,getClassName:p,getStyles:m,animation:u,hashId:c.hashId,onAllRemoved:h,getContainer:l},null),C=r([]);return i(C,()=>{C.value.length&&(C.value.forEach(e=>{switch(e.type){case`open`:y(e.config);break;case`close`:b(e.key);break;case`destroy`:x();break}}),C.value=[])}),[{open:e=>{let t=s(g,e);(t.key===null||t.key===void 0)&&(t.key=`vc-notification-${o}`,o+=1),C.value=[...C.value,{type:`open`,config:t}]},close:e=>{C.value=[...C.value,{type:`close`,key:e}]},destroy:()=>{C.value=[...C.value,{type:`destroy`}]}},S]}export{c as default};