import{C as l}from"./index-CKWbC5RE.js";import{i as p,t as v,e as w}from"./class-map-QEDp2jGy.js";const m=s=>s===null||typeof s!="object"&&typeof s!="function",g=s=>s.strings===void 0;const $=(s,t)=>{const e=s._$AN;if(e===void 0)return!1;for(const i of e)i._$AO?.(t,!1),$(i,t);return!0},_=s=>{let t,e;do{if((t=s._$AM)===void 0)break;e=t._$AN,e.delete(s),s=t}while(e?.size===0)},a=s=>{for(let t;t=s._$AM;s=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(s))break;e.add(s),N(t)}};function b(s){this._$AN!==void 0?(_(this),this._$AM=s,a(this)):this._$AM=s}function y(s,t=!1,e=0){const i=this._$AH,h=this._$AN;if(h!==void 0&&h.size!==0)if(t)if(Array.isArray(i))for(let o=e;o<i.length;o++)$(i[o],!1),_(i[o]);else i!=null&&($(i,!1),_(i));else $(this,s)}const N=s=>{s.type==v.CHILD&&(s._$AP??=y,s._$AQ??=b)};class x extends p{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),a(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&($(this,t),_(this))}setValue(t){if(g(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}class G{constructor(t){this.G=t}disconnect(){this.G=void 0}reconnect(t){this.G=t}deref(){return this.G}}class K{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise((t=>this.Z=t))}resume(){this.Z?.(),this.Y=this.Z=void 0}}const u=s=>!m(s)&&typeof s.then=="function",C=1073741823;class M extends x{constructor(){super(...arguments),this._$Cwt=C,this._$Cbt=[],this._$CK=new G(this),this._$CX=new K}render(...t){return t.find((e=>!u(e)))??l}update(t,e){const i=this._$Cbt;let h=i.length;this._$Cbt=e;const o=this._$CK,f=this._$CX;this.isConnected||this.disconnected();for(let n=0;n<e.length&&!(n>this._$Cwt);n++){const r=e[n];if(!u(r))return this._$Cwt=n,r;n<h&&r===i[n]||(this._$Cwt=C,h=0,Promise.resolve(r).then((async A=>{for(;f.get();)await f.get();const c=o.deref();if(c!==void 0){const d=c._$Cbt.indexOf(r);d>-1&&d<c._$Cwt&&(c._$Cwt=d,c.setValue(A))}})))}return l}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}const Z=w(M);export{x as f,Z as m};
