!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalthis?globalthis:n||self).lazyload=t()}(this,(function(){"use strict";function n(){return n=object.assign||function(n){for(var t=1;t1,r={elements_selector:".lazy",container:e||t?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1},c=function(t){return n({},r,t)},u=function(n,t){var e,i="lazyload::initialized",o=new n(t);try{e=new customevent(i,{detail:{instance:o}})}catch(n){(e=document.createevent("customevent")).initcustomevent(i,!1,!1,{instance:o})}window.dispatchevent(e)},l="src",s="srcset",f="sizes",d="poster",_="lloriginalattrs",g="loading",v="loaded",b="applied",p="error",h="native",m="data-",e="ll-status",i=function(n,t){return n.getattribute(m+t)},y=function(n){return i(n,e)},a=function(n,t){return function(n,t,e){var i="data-ll-status";null!==e?n.setattribute(i,e):n.removeattribute(i)}(n,0,t)},k=function(n){return a(n,null)},l=function(n){return null===y(n)},w=function(n){return y(n)===h},x=[g,v,b,p],o=function(n,t,e,i){n&&(void 0===i?void 0===e?n(t):n(t,e):n(t,e,i))},n=function(n,t){o?n.classlist.add(t):n.classname+=(n.classname?" ":"")+t},c=function(n,t){o?n.classlist.remove(t):n.classname=n.classname.replace(new regexp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},m=function(n){return n.lltempimage},z=function(n,t){if(t){var e=t._observer;e&&e.unobserve(n)}},r=function(n,t){n&&(n.loadingcount+=t)},t=function(n,t){n&&(n.toloadcount=t)},g=function(n){for(var t,e=[],i=0;t=n.children[i];i+=1)"source"===t.tagname&&e.push(t);return e},d=function(n,t){var e=n.parentnode;e&&"picture"===e.tagname&&g(e).foreach(t)},v=function(n,t){g(n).foreach(t)},f=[l],j=[l,d],p=[l,s,f],s=function(n){return!!n[_]},u=function(n){return n[_]},$=function(n){return delete n[_]},q=function(n,t){if(!s(n)){var e={};t.foreach((function(t){e[t]=n.getattribute(t)})),n[_]=e}},h=function(n,t){if(s(n)){var e=u(n);t.foreach((function(t){!function(n,t,e){e?n.setattribute(t,e):n.removeattribute(t)}(n,t,e[t])}))}},b=function(n,t,e){n(n,t.class_loading),a(n,g),e&&(r(e,1),o(t.callback_loading,n,e))},j=function(n,t,e){e&&n.setattribute(t,e)},k=function(n,t){j(n,f,i(n,t.data_sizes)),j(n,s,i(n,t.data_srcset)),j(n,l,i(n,t.data_src))},q={img:function(n,t){d(n,(function(n){q(n,p),k(n,t)})),q(n,p),k(n,t)},iframe:function(n,t){q(n,f),j(n,l,i(n,t.data_src))},video:function(n,t){v(n,(function(n){q(n,f),j(n,l,i(n,t.data_src))})),q(n,j),j(n,d,i(n,t.data_poster)),j(n,l,i(n,t.data_src)),n.load()}},w=["img","iframe","video"],x=function(n,t){!t||function(n){return n.loadingcount>0}(t)||function(n){return n.toloadcount>0}(t)||o(n.callback_finish,t)},y=function(n,t,e){n.addeventlistener(t,e),n.llevlisnrs[t]=e},z=function(n,t,e){n.removeeventlistener(t,e)},nn=function(n){return!!n.llevlisnrs},tn=function(n){if(nn(n)){var t=n.llevlisnrs;for(var e in t){var i=t[e];z(n,e,i)}delete n.llevlisnrs}},en=function(n,t,e){!function(n){delete n.lltempimage}(n),r(e,-1),function(n){n&&(n.toloadcount-=1)}(e),c(n,t.class_loading),t.unobserve_completed&&z(n,e)},on=function(n,t,e){var i=m(n)||n;nn(i)||function(n,t,e){nn(n)||(n.llevlisnrs={});var i="video"===n.tagname?"loadeddata":"load";y(n,i,t),y(n,"error",e)}(i,(function(o){!function(n,t,e,i){var o=w(t);en(t,e,i),n(t,e.class_loaded),a(t,v),o(e.callback_loaded,t,i),o||x(e,i)}(0,n,t,e),tn(i)}),(function(o){!function(n,t,e,i){var o=w(t);en(t,e,i),n(t,e.class_error),a(t,p),o(e.callback_error,t,i),o||x(e,i)}(0,n,t,e),tn(i)}))},an=function(n,t,e){!function(n){n.lltempimage=document.createelement("img")}(n),on(n,t,e),function(n){s(n)||(n[_]={backgroundimage:n.style.backgroundimage})}(n),function(n,t,e){var i=i(n,t.data_bg),o=i(n,t.data_bg_hidpi),r=a&&o?o:i;r&&(n.style.backgroundimage='url("'.concat(r,'")'),m(n).setattribute(l,r),b(n,t,e))}(n,t,e),function(n,t,e){var i=i(n,t.data_bg_multi),o=i(n,t.data_bg_multi_hidpi),r=a&&o?o:i;r&&(n.style.backgroundimage=r,function(n,t,e){n(n,t.class_applied),a(n,b),e&&(t.unobserve_completed&&z(n,t),o(t.callback_applied,n,e))}(n,t,e))}(n,t,e)},rn=function(n,t,e){!function(n){return w.indexof(n.tagname)>-1}(n)?an(n,t,e):function(n,t,e){on(n,t,e),function(n,t,e){var i=q[n.tagname];i&&(i(n,t),b(n,t,e))}(n,t,e)}(n,t,e)},cn=function(n){n.removeattribute(l),n.removeattribute(s),n.removeattribute(f)},un=function(n){d(n,(function(n){h(n,p)})),h(n,p)},ln={img:un,iframe:function(n){h(n,f)},video:function(n){v(n,(function(n){h(n,f)})),h(n,j),n.load()}},sn=function(n,t){(function(n){var t=ln[n.tagname];t?t(n):function(n){if(s(n)){var t=u(n);n.style.backgroundimage=t.backgroundimage}}(n)})(n),function(n,t){l(n)||w(n)||(c(n,t.class_entered),c(n,t.class_exited),c(n,t.class_applied),c(n,t.class_loading),c(n,t.class_loaded),c(n,t.class_error))}(n,t),k(n),$(n)},fn=["img","iframe","video"],dn=function(n){return n.use_native&&"loading"in htmlimageelement.prototype},_n=function(n,t,e){n.foreach((function(n){return function(n){return n.isintersecting||n.intersectionratio>0}(n)?function(n,t,e,i){var o=function(n){return x.indexof(y(n))>=0}(n);a(n,"entered"),n(n,e.class_entered),c(n,e.class_exited),function(n,t,e){t.unobserve_entered&&z(n,e)}(n,e,i),o(e.callback_enter,n,t,i),o||rn(n,e,i)}(n.target,n,t,e):function(n,t,e,i){l(n)||(n(n,e.class_exited),function(n,t,e,i){e.cancel_on_exit&&function(n){return y(n)===g}(n)&&"img"===n.tagname&&(tn(n),function(n){d(n,(function(n){cn(n)})),cn(n)}(n),un(n),c(n,e.class_loading),r(i,-1),k(n),o(e.callback_cancel,n,t,i))}(n,t,e,i),o(e.callback_exit,n,t,i))}(n.target,n,t,e)}))},gn=function(n){return array.prototype.slice.call(n)},vn=function(n){return n.container.queryselectorall(n.elements_selector)},bn=function(n){return function(n){return y(n)===p}(n)},pn=function(n,t){return function(n){return gn(n).filter(l)}(n||vn(t))},hn=function(n,e){var o=c(n);this._settings=o,this.loadingcount=0,function(n,t){i&&!dn(n)&&(t._observer=new intersectionobserver((function(e){_n(e,n,t)}),function(n){return{root:n.container===document?null:n.container,rootmargin:n.thresholds||n.threshold+"px"}}(n)))}(o,this),function(n,e){t&&window.addeventlistener("online",(function(){!function(n,t){var e;(e=vn(n),gn(e).filter(bn)).foreach((function(t){c(t,n.class_error),k(t)})),t.update()}(n,e)}))}(o,this),this.update(e)};return hn.prototype={update:function(n){var t,o,a=this._settings,r=pn(n,a);t(this,r.length),!e&&i?dn(a)?function(n,t,e){n.foreach((function(n){-1!==fn.indexof(n.tagname)&&function(n,t,e){n.setattribute("loading","lazy"),on(n,t,e),function(n,t){var e=q[n.tagname];e&&e(n,t)}(n,t),a(n,h)}(n,t,e)})),t(e,0)}(r,a,this):(o=r,function(n){n.disconnect()}(t=this._observer),function(n,t){t.foreach((function(t){n.observe(t)}))}(t,o)):this.loadall(r)},destroy:function(){this._observer&&this._observer.disconnect(),vn(this._settings).foreach((function(n){$(n)})),delete this._observer,delete this._settings,delete this.loadingcount,delete this.toloadcount},loadall:function(n){var t=this,e=this._settings;pn(n,e).foreach((function(n){z(n,t),rn(n,e,t)}))},restoreall:function(){var n=this._settings;vn(n).foreach((function(t){sn(t,n)}))}},hn.load=function(n,t){var e=c(t);rn(n,e)},hn.resetstatus=function(n){k(n)},t&&function(n,t){if(t)if(t.length)for(var e,i=0;e=t[i];i+=1)u(n,e);else u(n,t)}(hn,window.lazyloadoptions),hn}));