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