import{writable,derived}from"svelte/store";function createNotificationStore(t){const e=writable([]);function i(t,i,n="default",r){e.update((e=>[...e,{id:id(),type:n,message:t,link:i,timeout:r}]))}const n=derived(e,((t,i)=>{if(i(t),t.length>0){const i=setTimeout((()=>{e.update((t=>(t.shift(),t)))}),t[0].timeout);return()=>{clearTimeout(i)}}})),{subscribe:r}=n;return{subscribe:r,send:i,default:(t,e,n)=>i(t,e,"default",n),danger:(t,e,n)=>i(t,e,"danger",n),warning:(t,e,n)=>i(t,e,"warning",n),info:(t,e,n)=>i(t,e,"info",n),success:(t,e,n)=>i(t,e,"success",n)}}function id(){return"_"+Math.random().toString(36).substr(2,9)}export const notifications=createNotificationStore();