var S=Object.defineProperty;var y=a=>{throw TypeError(a)};var x=(a,e,t)=>e in a?S(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var A=(a,e,t)=>x(a,typeof e!="symbol"?e+"":e,t),T=(a,e,t)=>e.has(a)||y("Cannot "+t);var s=(a,e,t)=>(T(a,e,"read from private field"),t?t.call(a):e.get(a)),u=(a,e,t)=>e.has(a)?y("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(a):e.set(a,t),w=(a,e,t,i)=>(T(a,e,"write to private field"),i?i.call(a,t):e.set(a,t),t);import{A as E,W as D,X as k,Y as N,Z as F,_ as M,F as g,a0 as B,a1 as C,a2 as Y,a3 as H,a4 as I,a5 as L,a6 as O,a7 as P,a8 as W,a9 as X,aa as R}from"./mO2F3zLa.js";var d,l,c,_,v,m,b;class Z{constructor(e,t=!0){A(this,"anchor");u(this,d,new Map);u(this,l,new Map);u(this,c,new Map);u(this,_,new Set);u(this,v,!0);u(this,m,()=>{var e=E;if(s(this,d).has(e)){var t=s(this,d).get(e),i=s(this,l).get(t);if(i)D(i),s(this,_).delete(t);else{var n=s(this,c).get(t);n&&(s(this,l).set(t,n.effect),s(this,c).delete(t),n.fragment.lastChild.remove(),this.anchor.before(n.fragment),i=n.effect)}for(const[f,r]of s(this,d)){if(s(this,d).delete(f),f===e)break;const h=s(this,c).get(r);h&&(k(h.effect),s(this,c).delete(r))}for(const[f,r]of s(this,l)){if(f===t||s(this,_).has(f))continue;const h=()=>{if(Array.from(s(this,d).values()).includes(f)){var p=document.createDocumentFragment();C(r,p),p.append(F()),s(this,c).set(f,{effect:r,fragment:p})}else k(r);s(this,_).delete(f),s(this,l).delete(f)};s(this,v)||!i?(s(this,_).add(f),N(r,h,!1)):h()}}});u(this,b,e=>{s(this,d).delete(e);const t=Array.from(s(this,d).values());for(const[i,n]of s(this,c))t.includes(i)||(k(n.effect),s(this,c).delete(i))});this.anchor=e,w(this,v,t)}ensure(e,t){var i=E,n=Y();if(t&&!s(this,l).has(e)&&!s(this,c).has(e))if(n){var f=document.createDocumentFragment(),r=F();f.append(r),s(this,c).set(e,{effect:M(()=>t(r)),fragment:f})}else s(this,l).set(e,M(()=>t(this.anchor)));if(s(this,d).set(i,e),n){for(const[h,o]of s(this,l))h===e?i.skipped_effects.delete(o):i.skipped_effects.add(o);for(const[h,o]of s(this,c))h===e?i.skipped_effects.delete(o.effect):i.skipped_effects.add(o.effect);i.oncommit(s(this,m)),i.ondiscard(s(this,b))}else g&&(this.anchor=B),s(this,m).call(this)}}d=new WeakMap,l=new WeakMap,c=new WeakMap,_=new WeakMap,v=new WeakMap,m=new WeakMap,b=new WeakMap;function z(a,e,t=!1){g&&I();var i=new Z(a),n=t?L:0;function f(r,h){if(g){const p=O(a)===P;if(r===p){var o=W();X(o),i.anchor=o,R(!1),i.ensure(r,h),R(!0);return}}i.ensure(r,h)}H(()=>{var r=!1;e((h,o=!0)=>{r=!0,f(o,h)}),r||f(!1,null)},n)}export{Z as B,z as i};