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