import{c as n,r as p,d as o,p as u,a as d,b as l,h as m,e as _,m as v,s as b}from"./BtrLzPHK.js";class w{anchor;#t=new Map;#s=new Map;#e=new Map;#i=new Set;#a=!0;constructor(e,s=!0){this.anchor=e,this.#a=s}#h=()=>{var e=n;if(this.#t.has(e)){var s=this.#t.get(e),t=this.#s.get(s);if(t)p(t),this.#i.delete(s);else{var a=this.#e.get(s);a&&(this.#s.set(s,a.effect),this.#e.delete(s),a.fragment.lastChild.remove(),this.anchor.before(a.fragment),t=a.effect)}for(const[i,h]of this.#t){if(this.#t.delete(i),i===e)break;const r=this.#e.get(h);r&&(o(r.effect),this.#e.delete(h))}for(const[i,h]of this.#s){if(i===s||this.#i.has(i))continue;const r=()=>{if(Array.from(this.#t.values()).includes(i)){var c=document.createDocumentFragment();v(h,c),c.append(d()),this.#e.set(i,{effect:h,fragment:c})}else o(h);this.#i.delete(i),this.#s.delete(i)};this.#a||!t?(this.#i.add(i),u(h,r,!1)):r()}}};#r=e=>{this.#t.delete(e);const s=Array.from(this.#t.values());for(const[t,a]of this.#e)s.includes(t)||(o(a.effect),this.#e.delete(t))};ensure(e,s){var t=n,a=b();if(s&&!this.#s.has(e)&&!this.#e.has(e))if(a){var i=document.createDocumentFragment(),h=d();i.append(h),this.#e.set(e,{effect:l(()=>s(h)),fragment:i})}else this.#s.set(e,l(()=>s(this.anchor)));if(this.#t.set(t,e),a){for(const[r,f]of this.#s)r===e?t.skipped_effects.delete(f):t.skipped_effects.add(f);for(const[r,f]of this.#e)r===e?t.skipped_effects.delete(f.effect):t.skipped_effects.add(f.effect);t.oncommit(this.#h),t.ondiscard(this.#r)}else m&&(this.anchor=_),this.#h()}}export{w as B};
