import{$ as A,A as O,B as m,E as M,H as f,Q as N,S as a,W as k,X as D,aa as P,ea as W,ec as $,h as L,i as S,k as w,n as h,na as x,oa as j,q as z,qa as T,r as E,sa as B,ya as c}from"./chunk-NRDLQK44.js";function G(){return typeof window<"u"?window.navigator:void 0}function V(n){return!!(n.parentElement&&n.parentElement.nodeName.toLowerCase()==="picture")}function d(n){return n.nodeName.toLowerCase()==="img"}function F(n,e,t){return d(n)?t&&"srcset"in n?n.srcset=e:n.src=e:n.style.backgroundImage=`url('${e}')`,n}function I(n){return e=>{let t=e.parentElement.getElementsByTagName("source");for(let s=0;s<t.length;s++){let o=t[s].getAttribute(n);o&&("srcset"in t[s]?t[s].srcset=o:t[s].src=o)}}}var Y=I("defaultImage"),K=I("lazyLoad"),J=I("errorImage");function C(n){return(e,t,s)=>{d(e)&&V(e)&&n(e),t&&F(e,t,s)}}var Q=C(Y),U=C(K),X=C(J),b=class{constructor(){this.navigator=G()}setPlatformId(e){this.platformId=e}onDestroy(e){}onAttributeChange(e){}},l={loaded:"ng-lazyloaded",loading:"ng-lazyloading",failed:"ng-failed-lazyloaded"};function R(n,e){n.className=n.className.replace(e,"")}function p(n,e){n.className.includes(e)||(n.className+=` ${e}`)}function _(n,e){return n.className&&n.className.includes(e)}var v=class extends b{setup(e){Q(e.element,e.defaultImagePath,e.useSrcset),e.imagePath&&p(e.element,l.loading),_(e.element,l.loaded)&&R(e.element,l.loaded)}finally(e){p(e.element,l.loaded),R(e.element,l.loading)}loadImage(e){if(this.skipLazyLoading(e))return[e.imagePath];let{element:t,useSrcset:s,imagePath:o,decode:r}=e,i;return d(t)&&V(t)?(i=t.parentNode.cloneNode(!0).getElementsByTagName("img")[0],K(i),F(i,o,s)):(i=new Image,d(t)&&t.referrerPolicy&&(i.referrerPolicy=t.referrerPolicy),d(t)&&t.sizes&&(i.sizes=t.sizes),s&&"srcset"in i?i.srcset=o:i.src=o),r&&i.decode?i.decode().then(()=>o):new Promise((u,q)=>{i.onload=()=>u(o),i.onerror=()=>q(null)})}setErrorImage(e,t){let{element:s,useSrcset:o,errorImagePath:r}=t;X(s,r,o),p(s,l.failed)}setLoadedImage(e,t){let{element:s,useSrcset:o}=t;U(s,e,o)}isDisabled(){return $(this.platformId)&&!this.isBot()}skipLazyLoading(e){return this.isBot(e)}isBot(e){return this.navigator?.userAgent?/googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp|duckduckbot|prerender/i.test(this.navigator.userAgent):!1}},y=class extends v{constructor(){super(...arguments),this.observers=new WeakMap,this.intersectionSubject=new S,this.uniqKey={}}getObservable(e){if(this.skipLazyLoading(e))return h({isIntersecting:!0});if(e.customObservable)return e.customObservable;let t=e.scrollContainer||this.uniqKey,s={root:e.scrollContainer||null};e.offset&&(s.rootMargin=`${e.offset}px`);let o=this.observers.get(t);return o||(o=new IntersectionObserver(r=>this.loadingCallback(r),s),this.observers.set(t,o)),o.observe(e.element),L.create(r=>{let i=this.intersectionSubject.pipe(m(u=>u.target===e.element)).subscribe(r);return()=>{i.unsubscribe(),o.unobserve(e.element)}})}isVisible(e){return e.isIntersecting}loadingCallback(e){e.forEach(t=>this.intersectionSubject.next(t))}};function H(n,e){return t=>t.pipe(a(s=>e.onStateChange.emit({reason:"observer-emit",data:s})),m(s=>n.isVisible(s,e)),f(1),a(()=>e.onStateChange.emit({reason:"start-loading"})),E(()=>n.loadImage(e)),a(()=>e.onStateChange.emit({reason:"mount-image"})),a(s=>n.setLoadedImage(s,e)),a(()=>e.onStateChange.emit({reason:"loading-succeeded"})),z(()=>!0),M(s=>(e.onStateChange.emit({reason:"loading-failed",data:s}),n.setErrorImage(s,e),h(!1))),a(()=>{e.onStateChange.emit({reason:"finally"}),n.finally(e)}))}var Z=new D("LazyLoadImageHooks"),me=(()=>{class n{constructor(t,s,o,r){this.onStateChange=new x,this.elementRef=t,this.ngZone=s,this.propertyChanges$=new w,this.hooks=r,this.hooks.setPlatformId(o),this.uid=Math.random().toString(36).substr(2,9)}ngOnChanges(){this.debug===!0&&!this.debugSubscription&&(this.debugSubscription=this.onStateChange.subscribe(t=>console.log(t))),this.propertyChanges$.next({element:this.elementRef.nativeElement,imagePath:this.lazyImage,defaultImagePath:this.defaultImage,errorImagePath:this.errorImage,useSrcset:this.useSrcset,offset:this.offset?this.offset|0:0,scrollContainer:this.scrollTarget,customObservable:this.customObservable,decode:this.decode,onStateChange:this.onStateChange,id:this.uid})}ngAfterContentInit(){if(this.hooks.isDisabled())return null;this.ngZone.runOutsideAngular(()=>{this.loadSubscription=this.propertyChanges$.pipe(a(t=>this.hooks.onAttributeChange(t)),a(t=>t.onStateChange.emit({reason:"setup"})),a(t=>this.hooks.setup(t)),N(t=>t.imagePath?this.hooks.getObservable(t).pipe(H(this.hooks,t)):O())).subscribe({next:()=>null})})}ngOnDestroy(){this.propertyChanges$.pipe(f(1)).subscribe({next:t=>this.hooks.onDestroy(t)}).unsubscribe(),this.loadSubscription?.unsubscribe(),this.debugSubscription?.unsubscribe()}}return n.\u0275fac=function(t){return new(t||n)(c(T),c(j),c(B),c(Z))},n.\u0275dir=P({type:n,selectors:[["","lazyLoad",""]],inputs:{lazyImage:[0,"lazyLoad","lazyImage"],defaultImage:"defaultImage",errorImage:"errorImage",scrollTarget:"scrollTarget",customObservable:"customObservable",offset:"offset",useSrcset:"useSrcset",decode:"decode",debug:"debug"},outputs:{onStateChange:"onStateChange"},features:[W]}),n})(),fe=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=A({type:n}),n.\u0275inj=k({providers:[{provide:Z,useClass:y}]}),n})(),g=class n{constructor(e,t,s,o){this.left=e,this.top=t,this.right=s,this.bottom=o}static fromElement(e){let{left:t,top:s,right:o,bottom:r}=e.getBoundingClientRect();return t===0&&s===0&&o===0&&r===0?n.empty:new n(t,s,o,r)}static fromWindow(e){return new n(0,0,e.innerWidth,e.innerHeight)}inflate(e){this.left-=e,this.top-=e,this.right+=e,this.bottom+=e}intersectsWith(e){return e.left<this.right&&this.left<e.right&&e.top<this.bottom&&this.top<e.bottom}getIntersectionWith(e){let t=Math.max(this.left,e.left),s=Math.max(this.top,e.top),o=Math.min(this.right,e.right),r=Math.min(this.bottom,e.bottom);return o>=t&&r>=s?new n(t,s,o,r):n.empty}};g.empty=new g(0,0,0,0);export{me as a,fe as b};
