(()=>{function t(a,t,l,i){a.$parent.pagination={pageSize:_.parseInt(a.pageSize),page:1,nextBtnDisabled:!1,prevBtnDisabled:!0,option:void 0},this.pag=a.$parent.pagination;var n=this.pag;n.nextPage=function(){n.page<n.totalPages&&(n.page+=1,n.option=n.options[n.page-1],n.prevBtnDisabled=!1,n.page>=n.totalPages)&&(n.nextBtnDisabled=!0)},n.prevPage=function(){0<n.page&&(--n.page,n.option=n.options[n.page-1],n.nextBtnDisabled=!1,n.page<=1)&&(n.prevBtnDisabled=!0)},n.optionSelect=function(){n.page=n.option.page,n.page<=1?(n.prevBtnDisabled=!0,n.nextBtnDisabled=!1):(n.page>=n.totalPages?n.nextBtnDisabled=!0:n.nextBtnDisabled=!1,n.prevBtnDisabled=!1)},a.$watch("items",function(t){var e;_.isEqual(t,n.items)||(e=t&&t.length,n.totalPages=((t,e)=>{if(e<t)return _.ceil(t/e)})(e,n.pageSize),n.items=i(t),a.items=n.items,n.totalPages&&(n.options=((t,e,a,i)=>{for(var n=[],o=0;o<e;o++){var p=t[o*a],s=o===e-1?t[i-1]:t[o*a+a-1],g=l.getString("{{firstItem}} to {{lastItem}}",{firstItem:p,lastItem:s});n.push({firstItem:p,lastItem:s,label:g,startFrom:o*a,page:o+1})}return n})(n.items,n.totalPages,n.pageSize,e),n.option||(n.option=n.options[0])))})}t.$inject=["$scope","gettext","gettextCatalog","orderByFilter"],angular.module("c8y.ui").controller("c8yListPaginationCtrl",t)})();