import{at as o,w as a,aG as d}from"./BRMnbBOX.js";function p(s,u,t){if(s==null)return u(void 0),o;const e=a(()=>s.subscribe(u,t));return e.unsubscribe?()=>e.unsubscribe():e}const i=[];function _(s,u=o){let t=null;const e=new Set;function c(r){if(d(s,r)&&(s=r,t)){const b=!i.length;for(const n of e)n[1](),i.push(n,s);if(b){for(let n=0;n<i.length;n+=2)i[n][0](i[n+1]);i.length=0}}}function f(r){c(r(s))}function l(r,b=o){const n=[r,b];return e.add(n),e.size===1&&(t=u(c,f)||o),r(s),()=>{e.delete(n),e.size===0&&t&&(t(),t=null)}}return{set:c,update:f,subscribe:l}}function h(s){let u;return p(s,t=>u=t)(),u}export{h as g,p as s,_ as w};
