import{ab as r,i as l,ac as d,ad as _,g,f as c,ae as m}from"./DECkK3yg.js";function h(n,e,t){if(n==null)return e(void 0),r;const u=l(()=>n.subscribe(e,t));return u.unsubscribe?()=>u.unsubscribe():u}const o=[];function x(n,e){return{subscribe:y(n,e).subscribe}}function y(n,e=r){let t=null;const u=new Set;function f(i){if(d(n,i)&&(n=i,t)){const a=!o.length;for(const s of u)s[1](),o.push(s,n);if(a){for(let s=0;s<o.length;s+=2)o[s][0](o[s+1]);o.length=0}}}function b(i){f(i(n))}function p(i,a=r){const s=[i,a];return u.add(s),u.size===1&&(t=e(f,b)||r),i(n),()=>{u.delete(s),u.size===0&&t&&(t(),t=null)}}return{set:f,update:b,subscribe:p}}function z(n){let e;return h(n,t=>e=t)(),e}function q(n){c===null&&_(),m&&c.l!==null?k(c).m.push(n):g(()=>{const e=l(n);if(typeof e=="function")return e})}function D(n){c===null&&_(),q(()=>()=>l(n))}function k(n){var e=n.l;return e.u??={a:[],b:[],m:[]}}export{D as a,z as g,q as o,x as r,h as s,y as w};
