import './polyfills.server.mjs';
import{d as m}from"./chunk-IT3JGK4C.mjs";function D(i){return i&&typeof i.connect=="function"&&!(i instanceof m)}var o=(function(i){return i[i.REPLACED=0]="REPLACED",i[i.INSERTED=1]="INSERTED",i[i.MOVED=2]="MOVED",i[i.REMOVED=3]="REMOVED",i})(o||{}),d=class{viewCacheSize=20;_viewCache=[];applyChanges(s,c,t,n,h){s.forEachOperation((e,f,E)=>{let a,l;if(e.previousIndex==null){let _=()=>t(e,f,E);a=this._insertView(_,E,c,n(e)),l=a?o.INSERTED:o.REPLACED}else E==null?(this._detachAndCacheView(f,c),l=o.REMOVED):(a=this._moveView(f,E,c,n(e)),l=o.MOVED);h&&h({context:a?.context,operation:l,record:e})})}detach(){for(let s of this._viewCache)s.destroy();this._viewCache=[]}_insertView(s,c,t,n){let h=this._insertViewFromCache(c,t);if(h){h.context.$implicit=n;return}let e=s();return t.createEmbeddedView(e.templateRef,e.context,e.index)}_detachAndCacheView(s,c){let t=c.detach(s);this._maybeCacheView(t,c)}_moveView(s,c,t,n){let h=t.get(s);return t.move(h,c),h.context.$implicit=n,h}_maybeCacheView(s,c){if(this._viewCache.length<this.viewCacheSize)this._viewCache.push(s);else{let t=c.indexOf(s);t===-1?s.destroy():c.remove(t)}}_insertViewFromCache(s,c){let t=this._viewCache.pop();return t&&c.insert(t,s),t||null}};export{D as a,o as b,d as c};
