var Pagination=function(n){typeof n!="undefined"&&(this.selector={wrapper:"[data-js-pagination-wrapper]",item:"[data-js-pagination-item]",searcherGroup:"[data-js-pagination-searcher]",searcherField:"[data-js-pagination-searcher-field]",searcherButton:"[data-js-pagination-searcher-button]",searcherError:"[data-js-pagination-searcher-error]"},this.element={wrapper:undefined,list:undefined,searcher:undefined,searcherField:undefined,wrappingEl:undefined},this.property={markup:{prev:null,pages:[],next:null,searcher:null},number:{page:undefined,resultsPerPage:10,pages:undefined,results:undefined},callbacks:{onpage:undefined},baseUrl:""},this.init=function(){this.setup.init()},this.methods=function(){return{goToPage:function(t){var o=n,i=n.Pagination,s,r,f,e,u;i.property.number.page=t;i.methods.setBaseUrl();$(i.selector.wrapper).length==1&&(s=window.location,r=i.property.baseUrl+t,history&&history.pushState?(f=typeof n.property.parent.Filter!="undefined"?n.property.parent.Filter.property.parametersForAjax:null,history.pushState(f,"Page",r)):window.location=r);i.property.callbacks.onpage!==undefined&&i.property.callbacks.onpage();e=$(".h-wrapper").find("[data-js-fixed-wrapper]").first().outerHeight();u=o.elements.resultsTop.offset().top-e;$("body, html").animate({scrollTop:u>0?u:0},500)},setBaseUrl:function(){var u=n,i=n.Pagination,r=window.location.origin+window.location.pathname,t=new Map(window.location.search.substring(1).split("&").map(n=>[n.split("=")[0],n.split("=")[1]]));t.delete("page");i.property.baseUrl=r+"?"+[...t.entries(),["page",""]].map(n=>`${n[0]}${typeof n[1]!="undefined"?"=":""}${n[1]||""}`).join("&")}}}(),this.setup=function(){return{init:function(){var i=n,t=n.Pagination;t.property.number.results>t.property.number.resultsPerPage?(this.element(),t.element.wrapper.length&&t.element.list.length&&(this.pages(),this.prev(),this.next(),this.html())):t.element.wrapper=$(t.selector.wrapper,t.element.wrappingEl).first().hide()},element:function(){var i=n,t=n.Pagination;t.element.wrapper=$(t.selector.wrapper,t.element.wrappingEl).first();t.element.list=$(".e-pagination__list",t.element.wrapper);(typeof t.element.list=="undefined"||t.element.list.length==0)&&(t.element.list=$("<ul class='e-pagination__list'><\/ul>"),t.element.wrapper.append(t.element.list));t.element.wrapper.length&&t.element.list.length?t.element.wrapper.show():t.element.wrapper.hide()},pages:function(){var t=n.Pagination,v=10,u=10,o=1,f=t.property.number.pages,i=t.property.number.pages,h=t.property.number.page,c,s,l,r,a,e;for(t.property.number.page>i?t.property.number.page=i:t.property.number.page<1&&(t.property.number.page=1),t.methods.setBaseUrl(),c=!1,s=!1,i>v&&(h>v/2+1?(c=!0,u-=2,h<i-(u/2+1)?(s=!0,u-=2,o=h-Math.ceil(u/2),f=h+Math.ceil(u/2)):(f=i,o=i-(u-1))):(s=!0,u-=2,f=u)),c&&(l=o-1<1?1:o-1,e=["",'<li class="e-pagination__item" data-js-pagination-item>','<a href="'+t.property.baseUrl+'1" class="e-pagination__link" data-page="1"><span aria-hidden="true">1<\/span><\/a>',"<\/li>",'<li class="e-pagination__item" data-js-pagination-item>','<a href="'+t.property.baseUrl+l+'" class="e-pagination__link" data-page="'+l+'"><span aria-hidden="true">...<\/span><span class="sr-only">Previous Group<\/span><\/a>',"<\/li>",""].join(""),t.property.markup.pages.push(e)),r=o;r<=f;r++)e=["",'<li class="e-pagination__item'+(r===t.property.number.page?" is-current":"")+(r>99?" e-pagination__item--long":"")+'" data-js-pagination-item>',r===t.property.number.page?'<span class="e-pagination__link"><span>'+r.toString()+'<\/span><span class="sr-only"> - Current page<\/span><\/span>':'<a href="'+t.property.baseUrl+r.toString()+'" class="e-pagination__link" data-page="'+r.toString()+'"><span>'+r.toString()+"<\/span><\/a>","<\/li>",""].join(""),t.property.markup.pages.push(e);s&&(a=f+1>i?i:f+1,e=["",'<li class="e-pagination__item" data-js-pagination-item>','<a href="'+t.property.baseUrl+a+'" class="e-pagination__link" data-page="'+a+'"><span aria-hidden="true">...<\/span><span class="sr-only">Next Group<\/span><\/a>',"<\/li>",'<li class="e-pagination__item'+(i>99?" e-pagination__item--long":"")+'" data-js-pagination-item>','<a href="'+t.property.baseUrl+i+'" class="e-pagination__link" data-page="'+i+'"><span>'+i+"<\/span><\/a>","<\/li>",""].join(""),t.property.markup.pages.push(e));t.element.searcher==null&&(s||c)&&(t.element.searcher=$('<div class="e-pagination__searcher" data-js-pagination-searcher><\/div>'),t.element.wrapper.append(t.element.searcher),t.property.markup.searcher=["",'<label for="'+t.element.wrapper.attr("id")+'_txtGoToPage" class="e-pagination__searcher__label">Go to page:<\/label>','<div class="e-pagination__searcher__field">','<input type="numeric" id="'+t.element.wrapper.attr("id")+'_txtGoToPage" class="e-field" data-js-pagination-searcher-field />','<button type="button" class="e-pagination__searcher__field__button" data-js-pagination-searcher-button>Go<\/button>','<span class="e-pagination__searcher__error"  id="'+t.element.wrapper.attr("id")+'_goToPageError" data-js-pagination-searcher-error>Please enter a valid page number.<\/span>',"<\/div>",""].join(""))},prev:function(){var t=n.Pagination,i=(t.property.number.page-1).toString();t.property.markup.prev=["",'<li class="e-pagination__item" data-js-pagination-item>',t.property.number.page<=1?'<span class="e-pagination__prev">':'<a href="'+t.property.baseUrl+i+'" rel="prev" data-page="'+i+'" class="e-pagination__prev is-link">',Site.SVGMarkup("chevron-left"),'<span class="sr-only">Previous<\/span>',t.property.number.page<=1?"<\/span>":"<\/a>","<\/li>",""].join("")},next:function(){var t=n.Pagination,i=(t.property.number.page+1).toString();t.property.markup.next=["",'<li class="e-pagination__item" data-js-pagination-item>',t.property.number.page>=t.property.number.pages?'<span class="e-pagination__next">':'<a href="'+t.property.baseUrl+i+'" rel="next" data-page="'+i+'" class="e-pagination__next is-link">',Site.SVGMarkup("chevron-right"),'<span class="sr-only">Next<\/span>',t.property.number.page>=t.property.number.pages?"<\/span>":"<\/a>","<\/li>",""].join("")},html:function(){var t=n.Pagination,i=t.property.markup,r=[i.prev,i.pages.join(""),i.next].join("");t.element.list.html(r);t.element.searcher!=null&&(t.element.searcher.html(t.property.markup.searcher),t.element.searcherField=$(t.selector.searcherField,t.element.searcher));t.element.wrapper.show()}}}(),this.events=function(){return{init:function(){this.click();this.searchField()},click:function(){var i=n,t=n.Pagination;window.onpopstate=function(){i.Update()};$(document).on("click",function(n){var r=$(n.target),u,f,i;r.closest(t.selector.item).length&&t.element.wrappingEl.find($(n.target)).length&&(u=r.closest("a"),f=u.data("page"),u.length&&typeof f!="undefined"&&(t.methods.goToPage(f),n.preventDefault(),n.stopPropagation()));r.closest(t.selector.searcherButton).length&&t.element.wrappingEl.find($(n.target)).length&&(i=$(t.selector.searcherField,t.element.wrappingEl),isNaN(parseInt(i.val()))?($(t.selector.searcherError,wrappingEl).addClass("is-errored"),i.attr("aria-invalid","true"),i.attr("aria-described-by",$(t.selector.searcherError).attr("id"))):t.methods.goToPage(parseInt(i.val())))})},searchField:function(){$(document).on("keydown",function(t){var i=t.which;i===13&&n.Pagination.element.searcherField.is(":focus")&&n.Pagination.element.wrappingEl.find($(t.target)).length&&$(t.target).next().trigger("click")})}}}())}