var D=Object.defineProperty;var w=a=>{throw TypeError(a)};var I=(a,e,s)=>e in a?D(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s;var M=(a,e,s)=>I(a,typeof e!="symbol"?e+"":e,s),x=(a,e,s)=>e.has(a)||w("Cannot "+s);var t=(a,e,s)=>(x(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),A=(a,e,s,i)=>(x(a,e,"write to private field"),i?i.call(a,s):e.set(a,s),s);import{af as E,an as g,ag as N,W as F,a5 as B,x as R,B as k,I as T,am as S,a7 as P,X as W,E as X,aM as Z,Z as j,a0 as q,C as z,a1 as C}from"./CiQWViEs.js";var d,l,c,p,m,v,b;class G{constructor(e,s=!0){M(this,"anchor");u(this,d,new Map);u(this,l,new Map);u(this,c,new Map);u(this,p,new Set);u(this,m,!0);u(this,v,e=>{if(t(this,d).has(e)){var s=t(this,d).get(e),i=t(this,l).get(s);if(i)E(i),t(this,p).delete(s);else{var f=t(this,c).get(s);f&&(E(f.effect),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(F()),t(this,c).set(n,{effect:h,fragment:_})}else g(h);t(this,p).delete(n),t(this,l).delete(n)};t(this,m)||!i?(t(this,p).add(n),N(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,A(this,m,s)}ensure(e,s){var i=R,f=P();if(s&&!t(this,l).has(e)&&!t(this,c).has(e))if(f){var n=document.createDocumentFragment(),h=F();n.append(h),t(this,c).set(e,{effect:B(()=>s(h)),fragment:n})}else t(this,l).set(e,B(()=>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,v)),i.ondiscard(t(this,b))}else k&&(this.anchor=T),t(this,v).call(this,i)}}d=new WeakMap,l=new WeakMap,c=new WeakMap,p=new WeakMap,m=new WeakMap,v=new WeakMap,b=new WeakMap;function K(a,e,s=!1){var i;k&&(i=T,X());var f=new G(a),n=s?Z:0;function h(r,o){if(k){var _=j(i);if(r!==parseInt(_.substring(1))){var y=q();z(y),f.anchor=y,C(!1),f.ensure(r,o),C(!0);return}}f.ensure(r,o)}W(()=>{var r=!1;e((o,_=0)=>{r=!0,h(_,o)}),r||h(-1,null)},n)}export{G as B,K as i};
