let t=[],i=0;const s=4;let a=0,c=r=>{let f=[],e={get(){return e.lc||e.listen(()=>{})(),e.value},lc:0,listen(l){return e.lc=f.push(l),()=>{for(let u=i+s;u<t.length;)t[u]===l?t.splice(u,s):u+=s;let n=f.indexOf(l);~n&&(f.splice(n,1),--e.lc||e.off())}},notify(l,n){a++;let u=!t.length;for(let o of f)t.push(o,e.value,l,n);if(u){for(i=0;i<t.length;i+=s)t[i](t[i+1],t[i+2],t[i+3]);t.length=0}},off(){},set(l){let n=e.value;n!==l&&(e.value=l,e.notify(n))},subscribe(l){let n=e.listen(l);return l(e.value),n},value:r};return e};export{c as a,a as e};
