import{k as p,l as m,m as d,q as v,v as g,w as y,h as k,g as w,x as M,y as h,z as D,A as _,B as b,C as x,D as A,E as B,F,G as S}from"./tjbnEgXP.js";let o=!1,l=Symbol();function E(r,s,t){const e=t[s]??={store:null,source:v(void 0),unsubscribe:d};if(e.store!==r&&!(l in t))if(e.unsubscribe(),e.store=r??null,r==null)e.source.v=void 0,e.unsubscribe=d;else{var n=!0;e.unsubscribe=g(r,i=>{n?e.source.v=i:w(e.source,i)}),n=!1}return r&&l in t?y(r):k(e.source)}function N(){const r={};function s(){p(()=>{for(var t in r)r[t].unsubscribe();m(r,l,{enumerable:!1,value:!0})})}return[r,s]}function U(r){var s=o;try{return o=!1,[r(),o]}finally{o=s}}class q{anchor;#s=new Map;#t=new Map;#e=new Map;#i=new Set;#r=!0;constructor(s,t=!0){this.anchor=s,this.#r=t}#n=s=>{if(this.#s.has(s)){var t=this.#s.get(s),e=this.#t.get(t);if(e)M(e),this.#i.delete(t);else{var n=this.#e.get(t);n&&(this.#t.set(t,n.effect),this.#e.delete(t),n.fragment.lastChild.remove(),this.anchor.before(n.fragment),e=n.effect)}for(const[i,a]of this.#s){if(this.#s.delete(i),i===s)break;const f=this.#e.get(a);f&&(h(f.effect),this.#e.delete(a))}for(const[i,a]of this.#t){if(i===t||this.#i.has(i))continue;const f=()=>{if(Array.from(this.#s.values()).includes(i)){var u=document.createDocumentFragment();F(a,u),u.append(_()),this.#e.set(i,{effect:a,fragment:u})}else h(a);this.#i.delete(i),this.#t.delete(i)};this.#r||!e?(this.#i.add(i),D(a,f,!1)):f()}}};#a=s=>{this.#s.delete(s);const t=Array.from(this.#s.values());for(const[e,n]of this.#e)t.includes(e)||(h(n.effect),this.#e.delete(e))};ensure(s,t){var e=x,n=S();if(t&&!this.#t.has(s)&&!this.#e.has(s))if(n){var i=document.createDocumentFragment(),a=_();i.append(a),this.#e.set(s,{effect:b(()=>t(a)),fragment:i})}else this.#t.set(s,b(()=>t(this.anchor)));if(this.#s.set(e,s),n){for(const[f,c]of this.#t)f===s?e.unskip_effect(c):e.skip_effect(c);for(const[f,c]of this.#e)f===s?e.unskip_effect(c.effect):e.skip_effect(c.effect);e.oncommit(this.#n),e.ondiscard(this.#a)}else A&&(this.anchor=B),this.#n(e)}}export{q as B,E as a,U as c,N as s};
