import{$ as e}from"./iframe-DSGyX7_4.js";class a{constructor(t){if(!t.data("pagination")||t.data("items")>=t.children().length)return t.closest(".events-wrapper").next(".events-actions").find(".prev, .next").remove(),!1;this.list=t.addClass("initiated"),this.wrapper=t.closest(".events-wrapper"),this.items=t.children(),this.current=0,this.resizeTimer=null,this.scroll=this.list.data("scroll"),this.show=this.list.data("items"),this.scroll||(this.scroll=this.show),this.initButtons(),window.requestAnimationFrame(()=>{this.goTo(0),this.initResize()})}initResize(){e(window).on("resize",()=>{this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(()=>{this.goTo(this.current)},250)})}initButtons(){this.prevBtn=this.wrapper.next(".events-actions").find(".prev"),this.nextBtn=this.wrapper.next(".events-actions").find(".next"),this.nextBtn.on("click",t=>{t.preventDefault(),this.next()}),this.prevBtn.on("click",t=>{t.preventDefault(),this.prev()})}next(){this.current+this.scroll+this.show<this.items.length?(this.goTo(this.current+this.scroll),this.nextBtn.removeClass("disabled").removeAttr("disabled","disabled")):(this.goTo(this.items.length-this.show),this.nextBtn.addClass("disabled").attr("disabled","disabled")),this.prevBtn.removeClass("disabled").removeAttr("disabled","disabled")}prev(){this.current-this.scroll>0?(this.goTo(this.current-this.scroll),this.prevBtn.removeClass("disabled").removeAttr("disabled","disabled")):(this.goTo(0),this.prevBtn.addClass("disabled").attr("disabled","disabled")),this.nextBtn.removeClass("disabled").removeAttr("disabled","disabled")}goTo(t){const i=this.items.eq(t),s=this.items.eq(t+this.show-1);this.wrapper.css("height",s.position().top-i.position().top+s.outerHeight()+"px"),this.list.css("transform","translate3d(0, -"+i.position().top+"px, 0"),this.items.each((n,r)=>{n<t||n>t+this.show-1?e(r).find("a").attr("tabindex","-1"):e(r).find("a").removeAttr("tabindex")}),this.current=t}}e("body").on("ihk-init dynamic-component-loaded gfi-dynamic-init",function(){e('.events-list[data-pagination="true"]:not(.initiated)').each(function(o){new a(e(this))})});export{a as I};
